xref: /PHP-7.4/ext/oci8/tests/imp_res_get_3.phpt (revision 26dfce7f)
1--TEST--
2Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: basic test 3
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(__DIR__.'/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--INI--
18oci8.statement_cache_size = 0
19--FILE--
20<?php
21
22require(__DIR__.'/connect.inc');
23
24// Initialization
25
26$stmtarray = array(
27    "drop table imp_res_get_3_tab_1",
28    "create table imp_res_get_3_tab_1 (c1 number, c2 varchar2(10))",
29    "insert into imp_res_get_3_tab_1 values (1, 'abcde')",
30    "insert into imp_res_get_3_tab_1 values (2, 'fghij')",
31    "insert into imp_res_get_3_tab_1 values (3, 'klmno')",
32
33    "drop table imp_res_get_3_tab_2",
34    "create table imp_res_get_3_tab_2 (c3 varchar2(1))",
35    "insert into imp_res_get_3_tab_2 values ('t')",
36    "insert into imp_res_get_3_tab_2 values ('u')",
37    "insert into imp_res_get_3_tab_2 values ('v')",
38
39    "create or replace procedure imp_res_get_3_proc as
40      c1 sys_refcursor;
41      i pls_integer;
42    begin
43      for i in 1..30 loop  -- if this value is too big for Oracle's open_cursors, calling imp_res_get_3_proc() can fail with ORA-1000
44        open c1 for select * from imp_res_get_3_tab_1 order by 1;
45        dbms_sql.return_result(c1);
46        open c1 for select * from imp_res_get_3_tab_2 where rownum < 3 order by 1;
47        dbms_sql.return_result(c1);
48        open c1 for select * from dual;
49        dbms_sql.return_result (c1);
50      end loop;
51    end;"
52);
53
54oci8_test_sql_execute($c, $stmtarray);
55
56// Run Test
57
58echo "Test 1\n";
59
60$s = oci_parse($c, "begin imp_res_get_3_proc(); end;");
61oci_execute($s);
62
63while (($s1 = oci_get_implicit_resultset($s))) {
64    while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
65        foreach ($row as $item) {
66            echo "  ".$item;
67        }
68        echo "\n";
69    }
70}
71
72// Clean up
73
74$stmtarray = array(
75    "drop procedure imp_res_get_3_proc",
76    "drop table imp_res_get_3_tab_1",
77    "drop table imp_res_get_3_tab_2"
78);
79
80oci8_test_sql_execute($c, $stmtarray);
81
82?>
83===DONE===
84<?php exit(0); ?>
85--EXPECT--
86Test 1
87  1  abcde
88  2  fghij
89  3  klmno
90  t
91  u
92  X
93  1  abcde
94  2  fghij
95  3  klmno
96  t
97  u
98  X
99  1  abcde
100  2  fghij
101  3  klmno
102  t
103  u
104  X
105  1  abcde
106  2  fghij
107  3  klmno
108  t
109  u
110  X
111  1  abcde
112  2  fghij
113  3  klmno
114  t
115  u
116  X
117  1  abcde
118  2  fghij
119  3  klmno
120  t
121  u
122  X
123  1  abcde
124  2  fghij
125  3  klmno
126  t
127  u
128  X
129  1  abcde
130  2  fghij
131  3  klmno
132  t
133  u
134  X
135  1  abcde
136  2  fghij
137  3  klmno
138  t
139  u
140  X
141  1  abcde
142  2  fghij
143  3  klmno
144  t
145  u
146  X
147  1  abcde
148  2  fghij
149  3  klmno
150  t
151  u
152  X
153  1  abcde
154  2  fghij
155  3  klmno
156  t
157  u
158  X
159  1  abcde
160  2  fghij
161  3  klmno
162  t
163  u
164  X
165  1  abcde
166  2  fghij
167  3  klmno
168  t
169  u
170  X
171  1  abcde
172  2  fghij
173  3  klmno
174  t
175  u
176  X
177  1  abcde
178  2  fghij
179  3  klmno
180  t
181  u
182  X
183  1  abcde
184  2  fghij
185  3  klmno
186  t
187  u
188  X
189  1  abcde
190  2  fghij
191  3  klmno
192  t
193  u
194  X
195  1  abcde
196  2  fghij
197  3  klmno
198  t
199  u
200  X
201  1  abcde
202  2  fghij
203  3  klmno
204  t
205  u
206  X
207  1  abcde
208  2  fghij
209  3  klmno
210  t
211  u
212  X
213  1  abcde
214  2  fghij
215  3  klmno
216  t
217  u
218  X
219  1  abcde
220  2  fghij
221  3  klmno
222  t
223  u
224  X
225  1  abcde
226  2  fghij
227  3  klmno
228  t
229  u
230  X
231  1  abcde
232  2  fghij
233  3  klmno
234  t
235  u
236  X
237  1  abcde
238  2  fghij
239  3  klmno
240  t
241  u
242  X
243  1  abcde
244  2  fghij
245  3  klmno
246  t
247  u
248  X
249  1  abcde
250  2  fghij
251  3  klmno
252  t
253  u
254  X
255  1  abcde
256  2  fghij
257  3  klmno
258  t
259  u
260  X
261  1  abcde
262  2  fghij
263  3  klmno
264  t
265  u
266  X
267===DONE===
268