xref: /PHP-8.3/ext/oci8/tests/imp_res_get_3.phpt (revision a53e5617)
1--TEST--
2Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: basic test 3
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--INI--
20oci8.statement_cache_size = 0
21--FILE--
22<?php
23
24require __DIR__.'/connect.inc';
25
26// Initialization
27
28$stmtarray = array(
29    "drop table imp_res_get_3_tab_1",
30    "create table imp_res_get_3_tab_1 (c1 number, c2 varchar2(10))",
31    "insert into imp_res_get_3_tab_1 values (1, 'abcde')",
32    "insert into imp_res_get_3_tab_1 values (2, 'fghij')",
33    "insert into imp_res_get_3_tab_1 values (3, 'klmno')",
34
35    "drop table imp_res_get_3_tab_2",
36    "create table imp_res_get_3_tab_2 (c3 varchar2(1))",
37    "insert into imp_res_get_3_tab_2 values ('t')",
38    "insert into imp_res_get_3_tab_2 values ('u')",
39    "insert into imp_res_get_3_tab_2 values ('v')",
40
41    "create or replace procedure imp_res_get_3_proc as
42      c1 sys_refcursor;
43      i pls_integer;
44    begin
45      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
46        open c1 for select * from imp_res_get_3_tab_1 order by 1;
47        dbms_sql.return_result(c1);
48        open c1 for select * from imp_res_get_3_tab_2 where rownum < 3 order by 1;
49        dbms_sql.return_result(c1);
50        open c1 for select * from dual;
51        dbms_sql.return_result (c1);
52      end loop;
53    end;"
54);
55
56oci8_test_sql_execute($c, $stmtarray);
57
58// Run Test
59
60echo "Test 1\n";
61
62$s = oci_parse($c, "begin imp_res_get_3_proc(); end;");
63oci_execute($s);
64
65while (($s1 = oci_get_implicit_resultset($s))) {
66    while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
67        foreach ($row as $item) {
68            echo "  ".$item;
69        }
70        echo "\n";
71    }
72}
73
74// Clean up
75
76$stmtarray = array(
77    "drop procedure imp_res_get_3_proc",
78    "drop table imp_res_get_3_tab_1",
79    "drop table imp_res_get_3_tab_2"
80);
81
82oci8_test_sql_execute($c, $stmtarray);
83
84?>
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