Pascal Data Objects

function TPDO.lastInsertId: Int64;

Returns the ID of the last inserted row, or the last value from a sequence object, depending on the underlying driver.

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.

Return Values

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;

   db.execute_now ('INSERT INTO callsigns (callsign) VALUES (''CHARLIE'')');
   lastId := db.lastInsertId;
   writeln (format('Inserted into row %d', [lastId]);

This may output something like:

Inserted into row 15