bug37220.phpt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. --TEST--
  2. Bug #37220 (LOB Type mismatch when using windows & oci8.dll)
  3. --EXTENSIONS--
  4. oci8
  5. --SKIPIF--
  6. <?php
  7. $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
  8. require(__DIR__.'/skipif.inc');
  9. ?>
  10. --FILE--
  11. <?php
  12. require __DIR__.'/connect.inc';
  13. // Initialization
  14. $stmtarray = array(
  15. "create table bug37220_tab( mycolumn xmltype not null)",
  16. "insert into bug37220_tab values(xmltype('<THETAG myID=\"1234\"></THETAG>'))"
  17. );
  18. oci8_test_sql_execute($c, $stmtarray);
  19. // Now let's update the row where myId = 1234 and change the tag
  20. // 'THETAG' to 'MYTAG' (mycolumn is an XMLTYPE datatype and
  21. // bug37220_tab a normal Oracle table)
  22. $query = "UPDATE bug37220_tab
  23. SET bug37220_tab.mycolumn = updateXML(bug37220_tab.mycolumn,'/THETAG',xmltype.createXML(:data))
  24. WHERE existsNode(bug37220_tab.mycolumn,'/THETAG[@myID=\"1234\"]') = 1";
  25. $stmt = oci_parse ($c, $query);
  26. $clob = oci_new_descriptor($c, OCI_D_LOB);
  27. oci_bind_by_name($stmt, ':data', $clob, -1, OCI_B_CLOB);
  28. $clob->writeTemporary("<MYTAG/>", OCI_TEMP_CLOB);
  29. $success = oci_execute($stmt, OCI_COMMIT_ON_SUCCESS);
  30. oci_free_statement($stmt);
  31. $clob->close();
  32. // Query back the change
  33. $query = "select * from bug37220_tab";
  34. $stmt = oci_parse ($c, $query);
  35. oci_execute($stmt);
  36. while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) {
  37. foreach ($row as $item) {
  38. echo trim($item)."\n";
  39. }
  40. echo "\n";
  41. }
  42. // Cleanup
  43. $stmtarray = array(
  44. "drop table bug37220_tab"
  45. );
  46. oci8_test_sql_execute($c, $stmtarray);
  47. echo "Done\n";
  48. ?>
  49. --EXPECT--
  50. <MYTAG/>
  51. Done