[英]PHP/ORACLE oci_bind_by_name and RETURNING INTO to get PK
I'm doing a very basic insert into an Oracle DB, with a RETURNING INTO clause to get the primary key. 我正在使用RETURNING INTO子句来获取Oracle数据库中的主键,这是一个非常基本的插入。 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);
Problem found. 发现问题。 I was calling $theNEWKRID instead of $theNewKRID. 我叫$ theNEWKRID而不是$ theNewKRID。 My Bad. 我的错。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.