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