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