xref: /PHP-8.1/ext/oci8/tests/bug51291_2.phpt (revision b5a14e6c)
1--TEST--
2Bug #51291 (oci_error() doesn't report last error when called two times)
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7$target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs: different error messages from TimesTen
8require(__DIR__.'/skipif.inc');
9?>
10--FILE--
11<?php
12
13require(__DIR__.'/connect.inc');
14
15echo "\nTest 1 - Execute - after successful 2nd query with same statement\n";
16
17$s = oci_parse($c, "declare e exception; begin if :bv = 1 then raise e; end if; end;");
18$bv = 1;
19oci_bind_by_name($s, ":bv", $bv);
20$r = @oci_execute($s, OCI_DEFAULT);
21if (!$r) {
22    var_dump(oci_error(), oci_error($c), oci_error($s));
23    $bv = 0;
24    $r = oci_execute($s, OCI_DEFAULT);
25    echo "Execute status is ";
26    if (is_null($r)) echo "null";
27    else if ($r === false) echo "false";
28    else if ($r === true) echo "true";
29    else echo $r;
30    echo "\n";
31    echo "2nd call after successful execute\n";
32    var_dump(oci_error(), oci_error($c), oci_error($s));
33}
34
35?>
36--EXPECTF--
37Test 1 - Execute - after successful 2nd query with same statement
38bool(false)
39bool(false)
40array(4) {
41  ["code"]=>
42  int(6510)
43  ["message"]=>
44  string(72) "ORA-06510: PL/SQL: %s
45ORA-06512: %s"
46  ["offset"]=>
47  int(0)
48  ["sqltext"]=>
49  string(64) "declare e exception; begin if :bv = 1 then raise e; end if; end;"
50}
51Execute status is true
522nd call after successful execute
53bool(false)
54bool(false)
55bool(false)
56