function IPDOStatement.lastInsertId: Int64;
Returns the ID of the last inserted row, or the last value from a sequence object, depending on the underlying driver. This method would be normally used during database insertions using prepared statements.
Note: This method may not return a meaningful or consistent result across different PDO drivers, because the underlying database may not even support the notion of auto-increment fields or sequences.
This function returns a string representing the row ID of the last row that was inserted into the database. If the PDO driver does not support this capability, TPDO.lastInsertID returns -1;
function show_last_id: Int64; var sql: AnsiString; begin sql = 'INSERT INTO shopping_cart (item, cost) VALUES (:item, :cost)'; stmt := db.prepare_as_is (sql); stmt.bindValue('item', 15); stmt.bindValue('cost', 24.99); stmt.execute; Result := stmt.lastInsertId; end;