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