Retrieving Last Inserted ROWID In PHP/OCI

邮差的信 提交于 2019-12-01 09:00:29

问题


Is it possible to retrieve the rowid of the last inserted Oracle row in PHP? I was trying:

$statement = oci_parse($conn, "INSERT INTO myTable (...) VALUES ( ...)");
$results = oci_execute($statement);
while($row = oci_fetch_assoc($statement)) {
    $rowid = $row['ROWID'];
}

With no luck. I'm getting the error define not done before fetch or execute and fetch at the fetch line.


回答1:


Declare:

$var = "AAAV1vAAGAAIb4CAAC";

Use:

INSERT INTO myTable (...) VALUES ( ...)
RETURNING RowId INTO :p_val

Bind your variable to a PHP variable:

oci_bind_by_name($statement, ":p_val", $val, 18);


来源:https://stackoverflow.com/questions/20335113/retrieving-last-inserted-rowid-in-php-oci

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!