xref: /PHP-7.2/ext/oci8/tests/imp_res_close.phpt (revision a2c0f872)
1--TEST--
2Oracle Database 12c Implicit Result Sets: oci_free_statement #1
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// Initialization
23
24$stmtarray = array(
25    "create or replace procedure imp_res_close_proc as
26      c1 sys_refcursor;
27    begin
28      open c1 for select 1 from dual union all select 2 from dual order by 1;
29      dbms_sql.return_result(c1);
30      open c1 for select 3 from dual union all select 4 from dual order by 1;
31      dbms_sql.return_result(c1);
32      open c1 for select 5 from dual union all select 6 from dual order by 1;
33      dbms_sql.return_result(c1);
34    end;"
35);
36
37oci8_test_sql_execute($c, $stmtarray);
38
39// Run Test
40
41echo "Test 1\n";
42$s = oci_parse($c, "begin imp_res_close_proc(); end;");
43oci_execute($s);
44while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
45    foreach ($row as $item) {
46        echo "  ".$item;
47    }
48    echo "\n";
49    oci_free_statement($s);  // Free the implicit result handle
50}
51
52// Clean up
53
54$stmtarray = array(
55    "drop procedure imp_res_close_proc"
56);
57
58oci8_test_sql_execute($c, $stmtarray);
59
60?>
61===DONE===
62<?php exit(0); ?>
63--EXPECTF--
64Test 1
65  1
66
67Warning: oci_fetch_array(): supplied resource is not a valid oci8 statement resource in %simp_res_close.php on line %d
68===DONE===
69