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