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