xref: /PHP-8.2/ext/oci8/tests/imp_res_get_all.phpt (revision 72f47c0c)
1--TEST--
2Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: oci_fetch_all
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
8require(__DIR__.'/skipif.inc');
9preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches);
10if (!(isset($matches[0]) && $matches[1] >= 12)) {
11    die("skip expected output only valid when using Oracle Database 12c or greater");
12}
13preg_match('/^[[:digit:]]+/', oci_client_version(), $matches);
14if (!(isset($matches[0]) && $matches[0] >= 12)) {
15    die("skip works only with Oracle 12c or greater version of Oracle client libraries");
16}
17?>
18--FILE--
19<?php
20
21require(__DIR__.'/connect.inc');
22
23$plsql = "declare
24           c1 sys_refcursor;
25          begin
26            open c1 for select 1 from dual union all select 2 from dual;
27            dbms_sql.return_result(c1);
28            open c1 for select 3 from dual union all select 4 from dual;
29            dbms_sql.return_result(c1);
30            open c1 for select 5 from dual union all select 6 from dual;
31            dbms_sql.return_result(c1);
32          end;";
33
34// Run Test
35
36echo "Test 1\n";
37$s = oci_parse($c, $plsql);
38oci_execute($s);
39
40$s1 = oci_get_implicit_resultset($s);
41oci_fetch_all($s1, $res);
42var_dump($res);
43
44$s2 = oci_get_implicit_resultset($s);
45oci_fetch_all($s2, $res);
46var_dump($res);
47
48$s3 = oci_get_implicit_resultset($s);
49oci_fetch_all($s3, $res);
50var_dump($res);
51
52echo "\nTest 2\n";
53$s = oci_parse($c, $plsql);
54oci_execute($s);
55while (($s1 = oci_get_implicit_resultset($s))) {
56    $r = oci_fetch_all($s1, $res);
57    var_dump($res);
58}
59
60?>
61--EXPECT--
62Test 1
63array(1) {
64  [1]=>
65  array(2) {
66    [0]=>
67    string(1) "1"
68    [1]=>
69    string(1) "2"
70  }
71}
72array(1) {
73  [3]=>
74  array(2) {
75    [0]=>
76    string(1) "3"
77    [1]=>
78    string(1) "4"
79  }
80}
81array(1) {
82  [5]=>
83  array(2) {
84    [0]=>
85    string(1) "5"
86    [1]=>
87    string(1) "6"
88  }
89}
90
91Test 2
92array(1) {
93  [1]=>
94  array(2) {
95    [0]=>
96    string(1) "1"
97    [1]=>
98    string(1) "2"
99  }
100}
101array(1) {
102  [3]=>
103  array(2) {
104    [0]=>
105    string(1) "3"
106    [1]=>
107    string(1) "4"
108  }
109}
110array(1) {
111  [5]=>
112  array(2) {
113    [0]=>
114    string(1) "5"
115    [1]=>
116    string(1) "6"
117  }
118}
119