summaryrefslogtreecommitdiff
path: root/ext/oci8/tests/bug37220.phpt
blob: da4a8968f3687698ebb1bc357b5d527ce669b305 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
--TEST--
Bug #37220 (LOB Type mismatch when using windows & oci8.dll)
--SKIPIF--
<?php
$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
require(dirname(__FILE__).'/skipif.inc');
?>
--FILE--
<?php

require dirname(__FILE__).'/connect.inc';

// Initialization

$stmtarray = array(
	"create table bug37220_tab( mycolumn xmltype not null)",
	"insert into bug37220_tab values(xmltype('<THETAG myID=\"1234\"></THETAG>'))"
);

oci8_test_sql_execute($c, $stmtarray);

// Now let's update the row where myId = 1234 and change the tag
// 'THETAG' to 'MYTAG' (mycolumn is an XMLTYPE datatype and
// bug37220_tab a normal Oracle table)

$query = "UPDATE  bug37220_tab
  		  SET     bug37220_tab.mycolumn = updateXML(bug37220_tab.mycolumn,'/THETAG',xmltype.createXML(:data))
		  WHERE   existsNode(bug37220_tab.mycolumn,'/THETAG[@myID=\"1234\"]') = 1";
$stmt = oci_parse ($c, $query);
$clob = oci_new_descriptor($c, OCI_D_LOB);
oci_bind_by_name($stmt, ':data', $clob, -1, OCI_B_CLOB);
$clob->writetemporary("<MYTAG/>", OCI_TEMP_CLOB);
$success = oci_execute($stmt, OCI_COMMIT_ON_SUCCESS);
oci_free_statement($stmt); 	
$clob->close();

// Query back the change

$query = "select * from bug37220_tab";
$stmt = oci_parse ($c, $query);

oci_execute($stmt);

while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) {
	foreach ($row as $item) {
		echo trim($item)."\n";
	}
	echo "\n";
}

// Cleanup

$stmtarray = array(
	"drop table bug37220_tab"
);

oci8_test_sql_execute($c, $stmtarray);

echo "Done\n";

?>
--EXPECT--
<MYTAG/>

Done