xref: /PHP-7.2/ext/oci8/tests/imp_res_get_all.phpt (revision bdd67d81)
1--TEST--
2Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: oci_fetch_all
3--SKIPIF--
4<?php
5if (!extension_loaded('oci8')) die ("skip no oci8 extension");
6$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
7require(dirname(__FILE__).'/skipif.inc');
8preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches);
9if (!(isset($matches[0]) && $matches[1] >= 12)) {
10    die("skip expected output only valid when using Oracle Database 12c or greater");
11}
12preg_match('/^[[:digit:]]+/', oci_client_version(), $matches);
13if (!(isset($matches[0]) && $matches[0] >= 12)) {
14    die("skip works only with Oracle 12c or greater version of Oracle client libraries");
15}
16?>
17--FILE--
18<?php
19
20require(dirname(__FILE__).'/connect.inc');
21
22$plsql = "declare
23           c1 sys_refcursor;
24          begin
25            open c1 for select 1 from dual union all select 2 from dual;
26            dbms_sql.return_result(c1);
27            open c1 for select 3 from dual union all select 4 from dual;
28            dbms_sql.return_result(c1);
29            open c1 for select 5 from dual union all select 6 from dual;
30            dbms_sql.return_result(c1);
31          end;";
32
33// Run Test
34
35echo "Test 1\n";
36$s = oci_parse($c, $plsql);
37oci_execute($s);
38
39$s1 = oci_get_implicit_resultset($s);
40oci_fetch_all($s1, $res);
41var_dump($res);
42
43$s2 = oci_get_implicit_resultset($s);
44oci_fetch_all($s2, $res);
45var_dump($res);
46
47$s3 = oci_get_implicit_resultset($s);
48oci_fetch_all($s3, $res);
49var_dump($res);
50
51echo "\nTest 2\n";
52$s = oci_parse($c, $plsql);
53oci_execute($s);
54while (($s1 = oci_get_implicit_resultset($s))) {
55    $r = oci_fetch_all($s1, $res);
56    var_dump($res);
57}
58
59?>
60===DONE===
61<?php exit(0); ?>
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===DONE===
121