xref: /PHP-5.5/ext/oci8/tests/bug46994.phpt (revision c7a8bd6a)
1--TEST--
2Bug #46994 (CLOB size does not update when using CLOB IN OUT param in stored procedure)
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	"create or replace procedure bug46994_proc1(p1 in out nocopy clob) is
17		 begin
18			 dbms_lob.trim(p1, 0);
19			 dbms_lob.writeappend(p1, 26, 'This should be the output.');
20         end bug46994_proc1;",
21	"create or replace procedure bug46994_proc2(p1 in out nocopy clob) is
22		 begin
23			 dbms_lob.trim(p1, 0);
24			 dbms_lob.writeappend(p1, 37, 'The output should be even longer now.');
25         end bug46994_proc2;"
26);
27
28oci8_test_sql_execute($c, $stmtarray);
29
30// Run Test
31
32$myclob = oci_new_descriptor($c, OCI_D_LOB);
33$myclob->writeTemporary("some data", OCI_TEMP_CLOB);
34
35echo "Test 1\n";
36
37$s = oci_parse($c, "begin bug46994_proc1(:myclob); end;");
38oci_bind_by_name($s, ":myclob", $myclob, -1, SQLT_CLOB);
39oci_execute($s, OCI_DEFAULT);
40var_dump($myclob->load());
41
42echo "Test 2\n";
43
44$s = oci_parse($c, "begin bug46994_proc2(:myclob); end;");
45oci_bind_by_name($s, ":myclob", $myclob, -1, SQLT_CLOB);
46oci_execute($s, OCI_DEFAULT);
47var_dump($myclob->load());
48
49echo "Test 3\n";
50
51$s = oci_parse($c, "begin bug46994_proc1(:myclob); end;");
52oci_bind_by_name($s, ":myclob", $myclob, -1, SQLT_CLOB);
53oci_execute($s, OCI_DEFAULT);
54var_dump($myclob->load());
55
56echo "Test 4\n";
57
58var_dump($myclob->load());  // Use cached size code path
59
60// Cleanup
61
62$stmtarray = array(
63	"drop procedure bug46994_proc1",
64	"drop procedure bug46994_proc2"
65);
66
67oci8_test_sql_execute($c, $stmtarray);
68
69oci_close($c);
70
71?>
72===DONE===
73<?php exit(0); ?>
74--EXPECTF--
75Test 1
76string(26) "This should be the output."
77Test 2
78string(37) "The output should be even longer now."
79Test 3
80string(26) "This should be the output."
81Test 4
82string(26) "This should be the output."
83===DONE===
84