[fpc-pascal] How to insert a record and get the primary key with sqldb?

Martin Schreiber mse00000 at gmail.com
Sat Oct 22 15:44:35 CEST 2011

On Saturday 22 October 2011 15.21:40 Marco van de Voort wrote:
> In our previous episode, Felipe Monteiro de Carvalho said:
> > Ok, now I want to insert a record in my table and I would like to
> > obtain the auto-generated PrimaryKey
> This is a classic problem, since SQL simply doesn't support this.
> So all DBs do something else, for postgresql there are sequence objects
> that can be queried, while other allow to return the id of the
> autogenerated fields.
> Afaik sqldb does not abstract this yet.

MSEgui updates inserted primary key fields automatically for MySQL and SQLite3 
by "lastinsertid". IIRC sqldb does the same?
For database which support the "returning" clause tmse*field.providerflags1 
pf1_refreshinsert and pf1_refreshupdate can be used, this works for all 


More information about the fpc-pascal mailing list