On Fri, Nov 14, 2014 at 12:49 PM, silvioprog <[email protected]> wrote:
> On Fri, Nov 14, 2014 at 11:43 AM, Michael Van Canneyt < > [email protected]> wrote: > [...] > >> AFAIK Only sqlite does not (maybe it does today). But that is not a DBMS >> :-) > > > Yes. It would be nice execute the "last_insert_rowid()" to return it in > the same cursor (AFAIK, Android SDK use this mechanism in the > nativeExecuteForLastInsertedRowId). So it can be same to the MySQL > (LAST_INSERT_ID()). =) > > And you can use the TSQLite3Connection.getinsertid method, no? =/ > It works fine in SQLite (my "test" table have ten records and "test2" one record): procedure TForm1.Button1Click(Sender: TObject); var id1, id2: Int64; begin SQLQuery1.Close; SQLQuery1.SQL.Text := 'insert into test (foo) values (''TEST'')'; SQLQuery1.ExecSQL; id1 := SQLite3Connection1.GetInsertID; SQLQuery2.Close; SQLQuery2.SQL.Text := 'insert into test2 (foo) values (''TEST'');'; SQLQuery2.ExecSQL; id2 := SQLite3Connection1.GetInsertID; ShowMessageFmt('ID1: %d; ID2: %d', [id1, id2]); end; [Window Title] project1 [Content] ID1: 11; ID2: 2 [OK] I'll test it in MySQL ... -- Silvio Clécio My public projects - github.com/silvioprog
-- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
