xref: /PHP-7.4/ext/oci8/tests/bug71422.phpt (revision 26dfce7f)
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===DONE===
51<?php exit(0); ?>
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===DONE===
66