Hi Doriano As the description says, the last_inserted_id() is during the same connection reserved for the client. I would recommend to use a stored procedure. Indeed, why not delegate the SQL thing to the server. The first time it seems to be expensive, but it is not so. I would be helpful if necessary.
Regards, Werner(007) [EMAIL PROTECTED] schrieb: Message: 4 Date: Mon, 20 Oct 2008 09:54:18 +0200 From: Doriano Blengino <[EMAIL PROTECTED]> Subject: Re: [Gambas-user] gb.db autoincrement ? To: mailing list for gambas users <gambas-user@lists.sourceforge.net> Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Doriano Blengino ha scritto: > > [EMAIL PROTECTED] ha scritto: > > > >> >> But in case you are using mySQL there is the function LAST_INSERT_ID (), >> >> see: >> >> http://dev.mysql.com/doc/refman/5.1/en/information-functions.html#function_last-insert-id. >> >> >> >> >> > > About the Last_insert_ID(), I read about this function, but it seems it > > is not implemented in gambas. > > May be I can import it using "EXTERNAL sub (...) ..."; or perhaps is > > more simple to do a query, once a lock is in place. > > > I correct myself - probably I doesn't need to be implemented in gambas, because one can use it in a simple sql request. I will try it: db.exec("insert data in master table 'invoices'") lastinserted=db.exec("select last_insert_id() as last") Perhaps locks are still needed (or this last_insert_id() is "cached" in the client library? It would be good...) Thanks for your information, and cheers, Doriano ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user