xref: /PHP-7.3/ext/oci8/tests/imp_res_cancel.phpt (revision bdd67d81)
1--TEST--
2Oracle Database 12c Implicit Result Sets: oci_cancel
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$stmtarray = array(
23    "create or replace procedure imp_res_cancel_proc as
24      c1 sys_refcursor;
25      c2 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      open c2 for select 3 from dual;
30      dbms_sql.return_result (c2);
31    end;"
32);
33
34oci8_test_sql_execute($c, $stmtarray);
35
36// Run Test
37
38echo "Test 1\n";
39$s = oci_parse($c, "begin imp_res_cancel_proc(); end;");
40oci_execute($s);
41while (($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
42    foreach ($row as $item) {
43        echo "  ".$item;
44    }
45    echo "\n";
46    var_dump(oci_cancel($s));
47}
48
49// Clean up
50
51$stmtarray = array(
52    "drop procedure imp_res_cancel_proc"
53);
54
55oci8_test_sql_execute($c, $stmtarray);
56
57?>
58===DONE===
59<?php exit(0); ?>
60--EXPECT--
61Test 1
62  1
63bool(true)
64  2
65bool(true)
66  3
67bool(true)
68===DONE===
69