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