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