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