Reputation: 21
I'm doing a very basic insert into an Oracle DB, with a RETURNING INTO clause to get the primary key. I'm constantly getting a null return though, and I can't figure out for the life of me what the problem might be. Other than this problem, the row inserts perfectly fine. Code below:
$requestParentSQL = "INSERT INTO
KRANE_REQUEST (
DATE_REQUESTED,
DATE_EMAILED,
PERSON_ID,
AUTHORISER_ID
)
VALUES (
SYSDATE,
SYSDATE,
'$theUser',
'$theAuthoriser'
)
RETURNING
KRANE_REQUEST_ID
INTO
:NEW_KRID";
$oracleConnection = oci_connect(_DATABASEUSERNAME, _DATABASEPASSWORD, _DATABASE);
$oracleStatement = oci_parse($oracleConnection, $requestParentSQL);
oci_bind_by_name($oracleStatement, ':NEW_KRID', $theNewKRID, 8);
oci_execute($oracleStatement, OCI_DEFAULT);
oci_commit($oracleConnection);
oci_free_statement($oracleStatement);
oci_close($oracleConnection);
Upvotes: 1
Views: 2633
Reputation: 21
Problem found. I was calling $theNEWKRID instead of $theNewKRID. My Bad.
Upvotes: 1