|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-01-20 16:46 UTC] alvaro at demogracia dot com
Description:
------------
After upgrading from PHP/5.6.10 to 5.6.17 it's no longer possible to insert
3 (int) in a NUMBER(1,0) column because now it triggers:
ORA-01438: value larger than specified precision allowed for this column
Test script:
---------------
CREATE TABLE TEST (
FORMATO_IMPORTACION_ID NUMBER(1,0) DEFAULT 1 NOT NULL
);
<?php
$value = 3;
$conn = oci_connect('test', 'test', '//example.com/xe');
$stmt = oci_parse($conn, 'INSERT INTO TEST (FORMATO_IMPORTACION_ID) VALUES (:formato_importacion_id)');
oci_bind_by_name($stmt, ':formato_importacion_id', $value, -1, SQLT_INT);
oci_execute($stmt);
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 01:00:01 2025 UTC |
I've found more broken stuff. I'd say that using SQLT_INT is in general no longer functional. Switching to SQLT_CHR is not a valid workaround for all situations since certain queries may fail if they expect a number and receive a string. CREATE TABLE TEST ( TEST_ID NUMBER(*,0) NOT NULL, LABEL VARCHAR2(50 CHAR), CONSTRAINT TEST_PK PRIMARY KEY (TEST_ID) ); INSERT INTO TEST (TEST_ID, LABEL) VALUES (1, 'Foo'); COMMIT; SELECT * FROM TEST WHERE TEST_ID=1; <?php $conn = oci_connect('test', 'test', '//hera.mina.s/xe'); // Query returns one row $stmt = oci_parse($conn, 'SELECT LABEL AS RAW_QUERY FROM TEST WHERE TEST_ID=1'); oci_execute($stmt); while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) { var_dump($row); } // Bind parameters do not return results... $stmt = oci_parse($conn, 'SELECT LABEL AS NUMERIC_BIND_PARAMETER FROM TEST WHERE TEST_ID=:test_id'); $value = 1; oci_bind_by_name($stmt, ':test_id', $value, -1, SQLT_INT); oci_execute($stmt); while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) { var_dump($row); } // ... unless we stringify them $stmt = oci_parse($conn, 'SELECT LABEL AS STRING_BIND_PARAMETER FROM TEST WHERE TEST_ID=:test_id'); $value = 1; oci_bind_by_name($stmt, ':test_id', $value, -1, SQLT_CHR); oci_execute($stmt); while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) { var_dump($row); }