[Gambas-user] DataView Help

Benoit Minisini benoit.minisini at gambas-basic.org
Thu Jul 13 15:34:39 CEST 2023


Le 13/07/2023 à 15:16, Benoit Minisini a écrit :
> Le 13/07/2023 à 10:30, Gianluigi a écrit :
>> Hi Benoit,
>>
>> Sorry for the late reply, but I tried to do some testing.
>>
>> I am sure I am using the last well-compiled commit (I always delete 
>> the previous one).
>>
> 
> OK, I see: it's because the student id is a serial field, so its control 
> has no value (it is generated by the server at insertion time).
> 
> I don't think it's possible to get the last inserted record in that case 
> in a standard and database agnostic way... :-/
> 
> There is a function that returns the last generated id in MySQL (for 
> example), but what if you have *two* auto increment fields in your table?
> 

More info...

Both PostgreSQL and SQLite have a RETURNING keyword that allows to 
return the contents of records created by an INSERT INTO statement.

It will allow to find the newly inserted record reliably.

Alas MySQL does not have this feature! ⁏-(

-- 
Benoît Minisini.



More information about the User mailing list