I want to get the last row, which I inserted into a table in an Oracle 11g Express database. How can I do this?
$sql = "INSERT INTO table_name( field1, field2 ) VALUES ('foo','bar')
RETURNING ID INTO :mylastid";
$stmt = oci_parse($db, $sql);
oci_bind_by_name($stmt, "mylastid", $last_id, 8, SQLT_INT);
oci_execute($stmt);
echo "last inserted id is:".$last_id;
Tip: you have to use your id column name in {your_id_col_name} below...
"RETURNING {your_id_col_name} INTO :mylastid"