xref: /PHP-8.3/ext/oci8/tests/imp_res_5.phpt (revision a53e5617)
1--TEST--
2Oracle Database 12c Implicit Result Sets: oci_fetch_all
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_5_proc as
28      c1 sys_refcursor;
29    begin
30        open c1 for select 1 from dual union select 2 from dual;
31        dbms_sql.return_result (c1);
32    end;"
33);
34
35oci8_test_sql_execute($c, $stmtarray);
36
37// Run Test
38
39echo "Test 1\n";
40$s = oci_parse($c, "begin imp_res_5_proc(); end;");
41oci_execute($s);
42oci_fetch_all($s,$res);  // This will fail with ORA-24374
43var_dump($res);
44
45echo "\nTest 2\n";
46$s = oci_parse($c, "begin imp_res_5_proc(); end;");
47oci_execute($s);
48$r = oci_fetch_row($s);
49var_dump($r);
50oci_fetch_all($s, $res);  // This will fail with ORA-24374
51var_dump($res);
52$r = oci_fetch_row($s);
53var_dump($r);
54
55// Clean up
56
57$stmtarray = array(
58    "drop procedure imp_res_5_proc",
59);
60
61oci8_test_sql_execute($c, $stmtarray);
62
63?>
64--EXPECTF--
65Test 1
66
67Warning: oci_fetch_all(): ORA-24374: %s in %simp_res_5.php on line %d
68array(0) {
69}
70
71Test 2
72array(1) {
73  [0]=>
74  string(1) "1"
75}
76
77Warning: oci_fetch_all(): ORA-24374: %s in %simp_res_5.php on line %d
78array(0) {
79}
80array(1) {
81  [0]=>
82  string(1) "2"
83}
84