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