xref: /PHP-8.2/ext/oci8/tests/imp_res_4.phpt (revision 72f47c0c)
1--TEST--
2Oracle Database 12c Implicit Result Sets: oci_fetch
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--FILE--
19<?php
20
21require(__DIR__.'/connect.inc');
22
23// Initialization
24
25$stmtarray = array(
26    "create or replace procedure imp_res_4_proc as
27      c1 sys_refcursor;
28    begin
29        open c1 for select 1 from dual union select 2 from dual;
30        dbms_sql.return_result (c1);
31    end;"
32);
33
34oci8_test_sql_execute($c, $stmtarray);
35
36// Run Test
37
38echo "Test 1\n";
39$s = oci_parse($c, "begin imp_res_4_proc(); end;");
40oci_execute($s);
41oci_fetch($s);  // This will fail with ORA-24374
42var_dump(oci_result($s, 1));
43
44echo "\nTest 2\n";
45$s = oci_parse($c, "begin imp_res_4_proc(); end;");
46oci_execute($s);
47$r = oci_fetch_row($s);
48var_dump($r);
49oci_fetch($s);  // This will fail with ORA-24374
50var_dump(oci_result($s, 1));
51$r = oci_fetch_row($s);
52var_dump($r);
53
54// Clean up
55
56$stmtarray = array(
57    "drop procedure imp_res_4_proc",
58);
59
60oci8_test_sql_execute($c, $stmtarray);
61
62?>
63--EXPECTF--
64Test 1
65
66Warning: oci_fetch(): ORA-24374: %s in %simp_res_4.php on line %d
67bool(false)
68
69Test 2
70array(1) {
71  [0]=>
72  string(1) "1"
73}
74
75Warning: oci_fetch(): ORA-24374: %s in %simp_res_4.php on line %d
76bool(false)
77array(1) {
78  [0]=>
79  string(1) "2"
80}
81