xref: /PHP-8.1/ext/oci8/tests/bug46994.phpt (revision b5a14e6c)
1--TEST--
2Bug #46994 (CLOB size does not update when using CLOB IN OUT param in stored procedure)
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
8require(__DIR__.'/skipif.inc');
9?>
10--FILE--
11<?php
12
13require(__DIR__.'/connect.inc');
14
15// Initialization
16
17$stmtarray = array(
18    "create or replace procedure bug46994_proc1(p1 in out nocopy clob) is
19         begin
20             dbms_lob.trim(p1, 0);
21             dbms_lob.writeappend(p1, 26, 'This should be the output.');
22         end bug46994_proc1;",
23    "create or replace procedure bug46994_proc2(p1 in out nocopy clob) is
24         begin
25             dbms_lob.trim(p1, 0);
26             dbms_lob.writeappend(p1, 37, 'The output should be even longer now.');
27         end bug46994_proc2;"
28);
29
30oci8_test_sql_execute($c, $stmtarray);
31
32// Run Test
33
34$myclob = oci_new_descriptor($c, OCI_D_LOB);
35$myclob->writeTemporary("some data", OCI_TEMP_CLOB);
36
37echo "Test 1\n";
38
39$s = oci_parse($c, "begin bug46994_proc1(:myclob); end;");
40oci_bind_by_name($s, ":myclob", $myclob, -1, SQLT_CLOB);
41oci_execute($s, OCI_DEFAULT);
42var_dump($myclob->load());
43
44echo "Test 2\n";
45
46$s = oci_parse($c, "begin bug46994_proc2(:myclob); end;");
47oci_bind_by_name($s, ":myclob", $myclob, -1, SQLT_CLOB);
48oci_execute($s, OCI_DEFAULT);
49var_dump($myclob->load());
50
51echo "Test 3\n";
52
53$s = oci_parse($c, "begin bug46994_proc1(:myclob); end;");
54oci_bind_by_name($s, ":myclob", $myclob, -1, SQLT_CLOB);
55oci_execute($s, OCI_DEFAULT);
56var_dump($myclob->load());
57
58echo "Test 4\n";
59
60var_dump($myclob->load());  // Use cached size code path
61
62// Cleanup
63
64$stmtarray = array(
65    "drop procedure bug46994_proc1",
66    "drop procedure bug46994_proc2"
67);
68
69oci8_test_sql_execute($c, $stmtarray);
70
71oci_close($c);
72
73?>
74--EXPECT--
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