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