TAstaServerSocket.OnInsertAutoIncrementFetch
Applies
to
TAstaServerSocket
Declaration
type TAstaAutoIncrementInsertEvent = procedure(Sender:
TObject;
ClientSocket: TCustomWinSocket; AQuery: TComponent;
TheDatabase, TheTable, TheAutoIncField: string;
var AutoIncrementValue: Integer) of object;
property
OnInsertAutoIncrementFetch: TAstaAutoIncrementInsertEvent;
Description
The OnInsertAutoIncrementFetch event must be coded if you wish to retrieve auto increment field values
at the client. This event is used in conjunction with the TAstaClientDataSet's AutoIncrementField
and RefetchOnInsert
properties.
procedure
TForm1.AstaServerSocket1InsertAutoIncrementFetch(
Sender: TObject; ClientSocket: TCustomWinSocket;
AQuery: TComponent; TheDatabase, TheTable, TheAutoIncField string;
var AutoIncrementValue:
Integer);
begin
//put your code in here.
//Something like
with aQuery as TQuery do begin
SQL.Add('Select max('+TheAutoIncField+') from '+TheTable);
Open;
TheAutoIncrementValue=FieldByName(TheAutoIncField).AsInteger;
end;
end;
The above code is specific to your database. For Access, Paradox and Interbase 5.X the above code should work in calling MAX to get the last value used by the server for an auto increment field. For MS SQL Server, Sybase, and SQL Anywhere you would need to write code to access the @@identify variable. The AstaODBC server is already coded to identify these databases and make the appropriate call.