Oci_bind_by_name RETURNING INTO Truncates a value

When I insert a row into a table with more than 1000 records and try to return the row identifier (either from the / seq auto-run or from the value manually in the insert statement)

$db = OCILogon(DATABASE_LOGIN, DATABASE_PASSWORD, DATABASE_NAME); $mysqldate = date('Y/m/d G:i:s'); $db_vid_id = 748; $authorID = 310; $typeID = 2; $timecode = 47; $shortDescrip = "hello world"; $query = "INSERT INTO TESTTHOUSAND (ID, VIDEO_ID, AUTHOR_ID, TYPE_ID, DATE_CREATED, TIMECODE, SHORT_DESCRIPTION, APPROVED, IS_PUBLIC) VALUES(4067, :videoID, :authorID, :typeID, TO_DATE('$mysqldate','yyyy/mm/dd HH24:MI:SS'), :timecode, :shortDescrip, 0, 0) RETURNING ID INTO :id"; $stmt = oci_parse($db, $query); oci_bind_by_name($stmt, ':videoID', $db_vid_id); oci_bind_by_name($stmt, ':authorID', $authorID); oci_bind_by_name($stmt, ':typeID', $typeID); oci_bind_by_name($stmt, ':timecode', $timecode); oci_bind_by_name($stmt, ':shortDescrip', $shortDescrip); oci_bind_by_name($stmt, ':id', $theID); oci_execute($stmt); oci_free_statement($stmt); oci_commit($db); oci_close($db); echo $theID; 

This code runs correctly and the values ​​are stored correctly in the database. However, the value of $theID is 406, not 4067.

I am running PHP 5.2.6 and Oracle 10.1

Has anyone come across this before?

+6
sql database oracle php
source share
1 answer

I did a few more digging, and it seems that I need to indicate that it is SQLT_INT:

 oci_bind_by_name($stmt, ':id', $annotationID, -1, SQLT_INT); 

From http://www.php.net/manual/en/function.oci-bind-by-name.php#92334

for numbers use the default length (-1), but tell the oracle an integer

+10
source share

All Articles