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