xref: /PHP-8.0/ext/oci8/tests/imp_res_4.phpt (revision a555cc0b)
1--TEST--
2Oracle Database 12c Implicit Result Sets: oci_fetch
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(__DIR__.'/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(__DIR__.'/connect.inc');
21
22// Initialization
23
24$stmtarray = array(
25    "create or replace procedure imp_res_4_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_4_proc(); end;");
39oci_execute($s);
40oci_fetch($s);  // This will fail with ORA-24374
41var_dump(oci_result($s, 1));
42
43echo "\nTest 2\n";
44$s = oci_parse($c, "begin imp_res_4_proc(); end;");
45oci_execute($s);
46$r = oci_fetch_row($s);
47var_dump($r);
48oci_fetch($s);  // This will fail with ORA-24374
49var_dump(oci_result($s, 1));
50$r = oci_fetch_row($s);
51var_dump($r);
52
53// Clean up
54
55$stmtarray = array(
56    "drop procedure imp_res_4_proc",
57);
58
59oci8_test_sql_execute($c, $stmtarray);
60
61?>
62--EXPECTF--
63Test 1
64
65Warning: oci_fetch(): ORA-24374: %s in %simp_res_4.php on line %d
66bool(false)
67
68Test 2
69array(1) {
70  [0]=>
71  string(1) "1"
72}
73
74Warning: oci_fetch(): ORA-24374: %s in %simp_res_4.php on line %d
75bool(false)
76array(1) {
77  [0]=>
78  string(1) "2"
79}
80