[Gambas-user] mysql last_insert_id

Bruce bbruen at ...2308...
Tue Jul 17 13:49:42 CEST 2012


On Tue, 2012-07-17 at 04:14 -0700, Bill-Lancaster wrote:
> I have a table (editprojects) with "id" as primary key, serial, integer.
> There is only one record at the moment (id = 1)
>      hResult = hConn.Exec("SELECT last_insert_id() as id FROM editprojects")
> print hResult!id
> produces 0 not 1
> 
> Obviously my sql query is at fault but where?
> 
> I wonder if anyone can help.
Bill,
AFAIK in mysql last_insert_id is session and connection based, from the
limited info you give, it looks like you are trying to get the last
insert id outside a session or connection.
If so you could try "SELECT MAX(id) as last_insert_id FROM
editprojects".  If not, then a short trip down the web history of this
totally bungled concept from mysql....

Bruce





More information about the User mailing list