[fpc-pascal] MSSQL and ftAutoInc: FPC 2.6.5 changes the behavior of 2.6.2 but AutoInc not works yet

Martin Schreiber mse00000 at gmail.com
Fri Apr 25 08:13:54 CEST 2014


On Friday 25 April 2014 07:46:23 LacaK wrote:
> Do you have tried for ftAutoInc field simply set ReadOnly:=False; ?
> -Laco.
> P.S. there is feature request about automatic fetching of new values of
> idnetity columns, but implementing it in generic way for all supported
> SQLConnections is not trivial ;-)
>
In MSEgui I used flags in tfield.providerflags1 
(pf1_refreshinsert,pf1_refreshupdate) which trigger the use of 
the "returning" clause in insert or update statement if the DB supports it. 
Additionally there is tcustomsqlconnection.updateprimarykeyfield() which is 
called after insert, it automatically updates the primary key field field 
with the "last insert id" if the DB supports it.
The third option is to use tsequencelink which automatically fetches sequence 
values from the DB before inserting.

Martin



More information about the fpc-pascal mailing list