xref: /PHP-7.3/ext/oci8/tests/lob_018.phpt (revision 37652336)
1--TEST--
2fetching the same lob several times
3--SKIPIF--
4<?php
5$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
6require(dirname(__FILE__).'/skipif.inc');
7?>
8--FILE--
9<?php
10
11require(dirname(__FILE__).'/connect.inc');
12
13// Initialization
14
15$stmtarray = array(
16	"drop table lob_018_tab",
17	"create table lob_018_tab (mykey number, lob_1 clob)",
18);
19
20oci8_test_sql_execute($c, $stmtarray);
21
22echo "Test 1\n";
23
24$init = "insert into lob_018_tab (mykey, lob_1) values(1, empty_clob()) returning lob_1 into :mylob";
25$statement = oci_parse($c, $init);
26$clob = oci_new_descriptor($c, OCI_D_LOB);
27oci_bind_by_name($statement, ":mylob", $clob, -1, OCI_B_CLOB);
28oci_execute($statement, OCI_DEFAULT);
29$clob->save("data");
30
31oci_commit($c);
32
33$init = "insert into lob_018_tab (mykey, lob_1) values(2, empty_clob()) returning lob_1 into :mylob";
34$statement = oci_parse($c, $init);
35$clob = oci_new_descriptor($c, OCI_D_LOB);
36oci_bind_by_name($statement, ":mylob", $clob, -1, OCI_B_CLOB);
37oci_execute($statement, OCI_DEFAULT);
38$clob->save("long data");
39
40oci_commit($c);
41
42
43$query = 'select * from lob_018_tab order by mykey asc';
44$statement = oci_parse ($c, $query);
45oci_execute($statement, OCI_DEFAULT);
46
47while ($row = oci_fetch_array($statement, OCI_ASSOC)) {
48	$result = $row['LOB_1']->load();
49	var_dump($result);
50}
51
52echo "Test 2\n";
53
54$query = 'select * from lob_018_tab order by mykey desc';
55$statement = oci_parse ($c, $query);
56oci_execute($statement, OCI_DEFAULT);
57
58while ($row = oci_fetch_array($statement, OCI_ASSOC)) {
59	$result = $row['LOB_1']->load();
60	var_dump($result);
61}
62
63echo "Test 3 - bind with SQLT_CLOB (an alias for OCI_B_CLOB)\n";
64
65$init = "insert into lob_018_tab (mykey, lob_1) values(3, empty_clob()) returning lob_1 into :mylob";
66$statement = oci_parse($c, $init);
67$clob = oci_new_descriptor($c, OCI_D_LOB);
68oci_bind_by_name($statement, ":mylob", $clob, -1, SQLT_CLOB);
69oci_execute($statement, OCI_DEFAULT);
70$clob->save("more stuff");
71
72oci_commit($c);
73
74$query = 'select * from lob_018_tab where mykey = 3';
75$statement = oci_parse ($c, $query);
76oci_execute($statement, OCI_DEFAULT);
77
78while ($row = oci_fetch_array($statement, OCI_ASSOC)) {
79	$result = $row['LOB_1']->load();
80	var_dump($result);
81}
82
83// Cleanup
84
85$stmtarray = array(
86    "drop table lob_018_tab"
87);
88
89oci8_test_sql_execute($c, $stmtarray);
90
91?>
92===DONE===
93<?php exit(0); ?>
94--EXPECT--
95Test 1
96string(4) "data"
97string(9) "long data"
98Test 2
99string(9) "long data"
100string(4) "data"
101Test 3 - bind with SQLT_CLOB (an alias for OCI_B_CLOB)
102string(10) "more stuff"
103===DONE===
104