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