xref: /PHP-8.3/ext/oci8/tests/bug71422.phpt (revision a53e5617)
1--TEST--
2Bug #71422 (Fix ORA-01438: value larger than specified precision allowed for this column)
3--EXTENSIONS--
4oci8
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11
12require __DIR__.'/connect.inc';
13
14$stmtarray = array(
15    "DROP TABLE BUG71422_TEST",
16    "CREATE TABLE BUG71422_TEST (TEST_ID NUMBER(*,0) NOT NULL, LABEL VARCHAR2(50 CHAR), CONSTRAINT BUG71422_TEST_PK PRIMARY KEY (TEST_ID))",
17    "INSERT INTO BUG71422_TEST (TEST_ID, LABEL) VALUES (1, 'Foo')"
18);
19
20oci8_test_sql_execute($c, $stmtarray);
21
22$stmt = oci_parse($c, 'SELECT LABEL AS RAW_QUERY FROM BUG71422_TEST WHERE TEST_ID=1');
23oci_execute($stmt);
24while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) {
25    var_dump($row);
26}
27
28$stmt = oci_parse($c, 'SELECT LABEL AS NUMERIC_BIND_PARAMETER FROM BUG71422_TEST WHERE TEST_ID=:test_id');
29$value = 1;
30oci_bind_by_name($stmt, ':test_id', $value, -1, SQLT_INT);
31oci_execute($stmt);
32while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) {
33    var_dump($row);
34}
35
36$stmt = oci_parse($c, 'SELECT LABEL AS STRING_BIND_PARAMETER FROM BUG71422_TEST WHERE TEST_ID=:test_id');
37$value = 1;
38oci_bind_by_name($stmt, ':test_id', $value, -1, SQLT_CHR);
39oci_execute($stmt);
40while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) {
41    var_dump($row);
42}
43
44// Cleanup
45
46$stmtarray = array(
47    "DROP TABLE BUG71422_TEST"
48);
49oci8_test_sql_execute($c, $stmtarray);
50
51?>
52--EXPECT--
53array(1) {
54  ["RAW_QUERY"]=>
55  string(3) "Foo"
56}
57array(1) {
58  ["NUMERIC_BIND_PARAMETER"]=>
59  string(3) "Foo"
60}
61array(1) {
62  ["STRING_BIND_PARAMETER"]=>
63  string(3) "Foo"
64}
65