1--TEST--
2Oracle Database 12c Implicit Result Sets: test with a PL/SQL function
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 function imp_res_func_error return number as
26      c1 sys_refcursor;
27    begin
28      open c1 for select * from dual;
29      dbms_sql.return_result(c1);
30      return 1234;
31    end;"
32);
33
34oci8_test_sql_execute($c, $stmtarray);
35
36// Run Test
37
38echo "Test 1\n";
39$s = oci_parse($c, "select imp_res_func_error from dual");
40$r = oci_execute($s);   // This will fail with ORA-29478 in Oracle 12.1
41if ($r) {
42    while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
43        foreach ($row as $item) {
44            echo "  ".$item;
45        }
46        echo "\n";
47    }
48}
49// Clean up
50
51$stmtarray = array(
52    "drop function imp_res_func_error",
53);
54
55oci8_test_sql_execute($c, $stmtarray);
56
57?>
58--EXPECTF--
59Test 1
60
61Warning: oci_execute(): ORA-29478: %s
62ORA-06512: %s
63ORA-06512: %s
64ORA-06512: %s
65