xref: /PHP-8.3/ext/oci8/tests/imp_res_2.phpt (revision a53e5617)
1--TEST--
2Oracle Database 12c Implicit Result Sets: Zero Rows
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// Initialization
25
26$stmtarray = array(
27    "create or replace procedure imp_res_2_proc_a as
28      c1 sys_refcursor;
29    begin
30      open c1 for select * from dual where 1 = 0;
31      dbms_sql.return_result(c1);
32    end;",
33
34    "create or replace procedure imp_res_2_proc_b as
35      c1 sys_refcursor;
36    begin
37      open c1 for select * from dual;
38      dbms_sql.return_result(c1);
39      open c1 for select * from dual where 1 = 0;
40      dbms_sql.return_result(c1);
41    end;",
42
43    "create or replace procedure imp_res_2_proc_c as
44      c1 sys_refcursor;
45    begin
46      open c1 for select * from dual where 1 = 0;
47      dbms_sql.return_result(c1);
48      open c1 for select * from dual;
49      dbms_sql.return_result(c1);
50    end;"
51
52);
53
54oci8_test_sql_execute($c, $stmtarray);
55
56// Run Test
57
58echo "Test 1\n";
59$s = oci_parse($c, "begin imp_res_2_proc_a(); end;");
60oci_execute($s);
61while (($row = oci_fetch_row($s)) != false)
62    var_dump($row);
63
64echo "Test 2\n";
65$s = oci_parse($c, "begin imp_res_2_proc_b(); end;");
66oci_execute($s);
67while (($row = oci_fetch_row($s)) != false)
68    var_dump($row);
69
70echo "Test 2\n";
71$s = oci_parse($c, "begin imp_res_2_proc_c(); end;");
72oci_execute($s);
73while (($row = oci_fetch_row($s)) != false)
74    var_dump($row);
75
76// Clean up
77
78$stmtarray = array(
79    "drop procedure imp_res_2_proc_a",
80    "drop procedure imp_res_2_proc_b",
81    "drop procedure imp_res_2_proc_c"
82);
83
84oci8_test_sql_execute($c, $stmtarray);
85
86?>
87--EXPECT--
88Test 1
89Test 2
90array(1) {
91  [0]=>
92  string(1) "X"
93}
94Test 2
95array(1) {
96  [0]=>
97  string(1) "X"
98}
99