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