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