Is it possible to retrieve the rowid of the last inserted Oracle row in PHP? I was trying:
JavaScript
x
$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.
Advertisement
Answer
Declare:
JavaScript
$var = "AAAV1vAAGAAIb4CAAC";
Use:
JavaScript
INSERT INTO myTable ( ) VALUES ( )
RETURNING RowId INTO :p_val
Bind your variable to a PHP variable:
JavaScript
oci_bind_by_name($statement, ":p_val", $val, 18);