xref: /PHP-7.3/ext/oci8/tests/imp_res_5.phpt (revision a2c0f872)
1--TEST--
2Oracle Database 12c Implicit Result Sets: oci_fetch_all
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(dirname(__FILE__).'/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--FILE--
18<?php
19
20require(dirname(__FILE__).'/connect.inc');
21
22// Initialization
23
24$stmtarray = array(
25    "create or replace procedure imp_res_5_proc as
26      c1 sys_refcursor;
27    begin
28        open c1 for select 1 from dual union select 2 from dual;
29        dbms_sql.return_result (c1);
30    end;"
31);
32
33oci8_test_sql_execute($c, $stmtarray);
34
35// Run Test
36
37echo "Test 1\n";
38$s = oci_parse($c, "begin imp_res_5_proc(); end;");
39oci_execute($s);
40oci_fetch_all($s,$res);  // This will fail with ORA-24374
41var_dump($res);
42
43echo "\nTest 2\n";
44$s = oci_parse($c, "begin imp_res_5_proc(); end;");
45oci_execute($s);
46$r = oci_fetch_row($s);
47var_dump($r);
48oci_fetch_all($s, $res);  // This will fail with ORA-24374
49var_dump($res);
50$r = oci_fetch_row($s);
51var_dump($r);
52
53// Clean up
54
55$stmtarray = array(
56    "drop procedure imp_res_5_proc",
57);
58
59oci8_test_sql_execute($c, $stmtarray);
60
61?>
62===DONE===
63<?php exit(0); ?>
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===DONE===
85