After I place a row right into a table with 1000+ records, and try to return the row ID (whether it is from an autoincrement trigger/seq, or from setting the worthiness by hand within the place statement), I recieve a cut down value:
$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 executes correctly, and also the values are properly saved within the database. However, the need for
$theID is 406, not 4067.
I'm running PHP 5.2.6 and Oracle 10.1
Has anybody experienced this before?
I've done more digging around also it seems that I have to specify that this can be a SQLT_INT:
oci_bind_by_name($stmt, ':id', $annotationID, -1, SQLT_INT);
for numerics make use of the default length (-1) but tell oracle its an integer