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