commit_002.phpt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. --TEST--
  2. Test oci_commit failure
  3. --EXTENSIONS--
  4. oci8
  5. --SKIPIF--
  6. <?php
  7. $target_dbs = array('oracledb' => true, 'timesten' => false); // test runs on these DBs
  8. require(__DIR__.'/skipif.inc');
  9. ?>
  10. --FILE--
  11. <?php
  12. require(__DIR__.'/connect.inc');
  13. // Initialization
  14. $stmtarray = array(
  15. "drop table commit_002_tab",
  16. "create table commit_002_tab
  17. ( x int constraint commit_002_tab_check_x check ( x > 0 ) deferrable initially immediate,
  18. y int constraint commit_002_tab_check_y check ( y > 0 ) deferrable initially deferred)"
  19. );
  20. oci8_test_sql_execute($c, $stmtarray);
  21. // Run Test
  22. echo "First Insert\n";
  23. $s = oci_parse($c, "insert into commit_002_tab values (-1, 1)");
  24. $r = @oci_execute($s, OCI_DEFAULT);
  25. if (!$r) {
  26. $m = oci_error($s);
  27. echo 'Could not execute: '. $m['message'] . "\n";
  28. }
  29. $r = oci_commit($c);
  30. if (!$r) {
  31. $m = oci_error($c);
  32. echo 'Could not commit: '. $m['message'] . "\n";
  33. }
  34. echo "Second Insert\n";
  35. $s = oci_parse($c, "insert into commit_002_tab values (1, -1)");
  36. $r = @oci_execute($s, OCI_NO_AUTO_COMMIT);
  37. if (!$r) {
  38. $m = oci_error($s);
  39. echo 'Could not execute: '. $m['message'] . "\n";
  40. }
  41. $r = oci_commit($c);
  42. if (!$r) {
  43. $m = oci_error($c);
  44. echo 'Could not commit: '. $m['message'] . "\n";
  45. }
  46. // Clean up
  47. $stmtarray = array(
  48. "drop table commit_002_tab"
  49. );
  50. oci8_test_sql_execute($c, $stmtarray);
  51. ?>
  52. --EXPECTF--
  53. First Insert
  54. Could not execute: ORA-02290: %s (%s.COMMIT_002_TAB_CHECK_X) %s
  55. Second Insert
  56. Warning: oci_commit(): ORA-02091: %s
  57. ORA-02290: %s (%s.COMMIT_002_TAB_CHECK_Y) %s in %scommit_002.php on line %d
  58. Could not commit: ORA-02091: %s
  59. ORA-02290: %s (%s.COMMIT_002_TAB_CHECK_Y) %s