Select last insert row id lazarus / 16-Databases ---------------------------------------------------------------------- LemonParty · 2025-11-05 16:41 I have this code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TdmSQLite.Insert(Path: String; Archive: TByteDynArray): SizeInt;begin  Result:= -1;  Query.Close;  Query.SQL.Text:= 'INSERT INTO Backup(Path, Archive) VALUES (:Path, :Archive)';  Query.ParamByName('Path').AsString:= Path;  Query.ParamByName('Archive').AsBlob:= Archive;  Query.ExecSQL;  Tran.Commit;   Query.SQL.Text:= 'SELECT last_insert_rowid()';  Query.Open;  Result:= Query.Fields[0].AsInteger;end; And I have a doubt. Should I put Transaction.Commit after or before "SELECT last_insert_rowid()"? ---------------------------------------------------------------------- Sieben · 2025-11-05 17:30 Before - insert action has to be finalized to produce a valid ID. And you might as well use TSQLite3Connection.GetInsertID instead of your Query. ---------------------------------------------------------------------- LemonParty · 2025-11-05 17:37 Thank you. ---------------------------------------------------------------------- Zvoni · 2025-11-05 17:58 Or implement a Callback like described here: http://sqlite.org/c3ref/update_hook.html The it's basically like an Event