xref: /PHP-5.5/ext/oci8/tests/bug51291_2.phpt (revision c7a8bd6a)
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(dirname(__FILE__).'/skipif.inc');
7?>
8--FILE--
9<?php
10
11require(dirname(__FILE__).'/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===DONE===
35<?php exit(0); ?>
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===DONE===
57