1--TEST--
2Oracle Database 12c Implicit Result Sets: oci_get_implicit_resultset: Execute twice
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 = "declare
25      c1 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    end;";
30
31// Run Test
32
33echo "Test 1\n";
34
35$s = oci_parse($c, $plsql);
36oci_execute($s);
37
38$s1 = oci_get_implicit_resultset($s);
39oci_execute($s1);
40oci_execute($s1);  // execute twice; should be NOP
41while (($row = oci_fetch_array($s1, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
42    foreach ($row as $item) {
43        echo "  ".$item;
44    }
45    echo "\n";
46}
47oci_free_statement($s);
48
49
50?>
51--EXPECT--
52Test 1
53  1
54  2
55