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