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