4
<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
8
require(dirname(__FILE__).'/connect.inc');
13
"drop table xmltype_02_tab",
14
"create table xmltype_02_tab (warehouse_id number, warehouse_spec xmltype)",
17
foreach ($stmtarray as $stmt) {
18
$s = oci_parse($c, $stmt);
19
$r = @oci_execute($s);
22
if (!in_array($m['code'], array( // ignore expected errors
23
942 // table or view does not exist
24
, 2289 // sequence does not exist
25
, 4080 // trigger does not exist
27
echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
37
// Delete any current entry
38
$s = oci_parse($c, "delete from xmltype_02_tab where warehouse_id = :id");
39
oci_bind_by_name($s, ':id', $id);
42
// XML data to be inserted
46
<WarehouseId>1</WarehouseId>
47
<WarehouseName>Southlake, Texas</WarehouseName>
48
<Building>Owned</Building>
51
<DockType>Rear load</DockType>
52
<WaterAccess>true</WaterAccess>
53
<RailAccess>N</RailAccess>
54
<Parking>Street</Parking>
55
<VClearance>10</VClearance>
59
echo "Test 1 Insert new XML data using a temporary CLOB\n";
61
"insert into xmltype_02_tab (warehouse_id, warehouse_spec)
62
values (:id, XMLType(:clob))");
63
oci_bind_by_name($s, ':id', $id);
64
$lob = oci_new_descriptor($c, OCI_D_LOB);
65
oci_bind_by_name($s, ':clob', $lob, -1, OCI_B_CLOB);
66
$lob->writeTemporary($xml);
71
$s = oci_parse($c, 'select xmltype.getclobval(warehouse_spec)
72
from xmltype_02_tab where warehouse_id = :id');
73
$r = oci_bind_by_name($s, ':id', $id);
75
$row = oci_fetch_array($s, OCI_NUM);
79
echo "Test 2 Manipulate the data using SimpleXML\n";
81
$sx = simplexml_load_string((binary)$row[0]->load());
85
$sx->Docks -= 1; // change the data
89
echo "Test 3: Update changes using a temporary CLOB\n";
91
$s = oci_parse($c, 'update xmltype_02_tab
92
set warehouse_spec = XMLType(:clob)
93
where warehouse_id = :id');
94
oci_bind_by_name($s, ':id', $id);
95
$lob = oci_new_descriptor($c, OCI_D_LOB);
96
oci_bind_by_name($s, ':clob', $lob, -1, OCI_B_CLOB);
97
$lob->writeTemporary($sx->asXml());
101
// Query the changed row back and print it
102
$s = oci_parse($c, 'select xmltype.getclobval(warehouse_spec)
103
from xmltype_02_tab where warehouse_id = :id');
104
$r = oci_bind_by_name($s, ':id', $id);
106
$row = oci_fetch_array($s, OCI_NUM);
107
var_dump($row[0]->load());
112
//require(dirname(__FILE__).'/drop_table.inc');
115
"drop table xmltype_02_tab"
118
foreach ($stmtarray as $stmt) {
119
$s = oci_parse($c, $stmt);
129
Test 1 Insert new XML data using a temporary CLOB
132
object(OCI-Lob)#%d (1) {
133
[%u|b%"descriptor"]=>
134
resource(%d) of type (oci8 descriptor)
137
Test 2 Manipulate the data using SimpleXML
138
object(SimpleXMLElement)#%d (10) {
139
[%u|b%"WarehouseId"]=>
140
%unicode|string%(1) "1"
141
[%u|b%"WarehouseName"]=>
142
%unicode|string%(16) "Southlake, Texas"
144
%unicode|string%(5) "Owned"
146
%unicode|string%(5) "25000"
148
%unicode|string%(1) "2"
150
%unicode|string%(9) "Rear load"
151
[%u|b%"WaterAccess"]=>
152
%unicode|string%(4) "true"
153
[%u|b%"RailAccess"]=>
154
%unicode|string%(1) "N"
156
%unicode|string%(6) "Street"
157
[%u|b%"VClearance"]=>
158
%unicode|string%(2) "10"
160
object(SimpleXMLElement)#%d (10) {
161
[%u|b%"WarehouseId"]=>
162
%unicode|string%(1) "1"
163
[%u|b%"WarehouseName"]=>
164
%unicode|string%(16) "Southlake, Texas"
166
%unicode|string%(5) "Owned"
168
%unicode|string%(5) "25000"
170
%unicode|string%(1) "1"
172
%unicode|string%(9) "Rear load"
173
[%u|b%"WaterAccess"]=>
174
%unicode|string%(4) "true"
175
[%u|b%"RailAccess"]=>
176
%unicode|string%(1) "N"
178
%unicode|string%(6) "Street"
179
[%u|b%"VClearance"]=>
180
%unicode|string%(2) "10"
182
Test 3: Update changes using a temporary CLOB
183
%unicode|string%(331) "<?xml version="1.0"?>
185
<WarehouseId>1</WarehouseId>
186
<WarehouseName>Southlake, Texas</WarehouseName>
187
<Building>Owned</Building>
190
<DockType>Rear load</DockType>
191
<WaterAccess>true</WaterAccess>
192
<RailAccess>N</RailAccess>
193
<Parking>Street</Parking>
194
<VClearance>10</VClearance>
b'\\ No newline at end of file'