1--TEST--
2Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: oci_cancel
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$plsql =
23    "declare
24      c1 sys_refcursor;
25      c2 sys_refcursor;
26    begin
27      open c1 for select 1 from dual union all select 2 from dual;
28      dbms_sql.return_result(c1);
29      open c2 for select 3 from dual;
30      dbms_sql.return_result (c2);
31    end;";
32
33// Run Test
34
35echo "Test 1\n";
36$s = oci_parse($c, $plsql);
37oci_execute($s);
38while (($s1 = oci_get_implicit_resultset($s))) {
39    while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
40        foreach ($row as $item) {
41            echo "  ".$item;
42        }
43        echo "\n";
44        oci_cancel($s1);
45    }
46}
47
48?>
49--EXPECT--
50Test 1
51  1
52  3
53