bug51291_2.phpt 1.4 KB

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