TAstaClientDataSet.AutoIncrementField
Applies to
TAstaClientDataSet
TAstaProvider
Declaration
property
AutoIncrementField: string;
Description
The AutoIncrement property facilitates working with auto increment values.
When you utilize ASTA's ability to automatically generate SQL, ASTA generates SQL for all the fields including your database's auto increment fields, but the auto increment field must not appear in Update or Insert statements, those values must be assigned by the database itself. Specifying the auto increment field in the AstaClientDataSet's AutoIncrementField property allows you to overcome this problem. When you specify the AutoIncrement field, ASTA does not include that field when it generates Update or Insert statements. The proper SQL is generated for the remaining fields and the database correctly assigns the auto increment value. If there are other fields that you do NOT want ASTA to include in Insert or Update statements, mark them as read only.
In order to allow you to work easily with auto increment values at the client (or to update those values if they are being displayed to the end user), ASTA provides an easy way for you to retrieve those values after an Insert statement. If the auto increment field is included as one of the fields in the RefetchOnInsert property, then the value in the AstaClientDataSet will be automatically updated after each transaction that includes any Insert statements.
If an AutoIncrementField is defined and included in this list of fields, then you must code the OnInsertAutoIncrementFetch event on the TAstaServerSocket. For Paradox and Access a call to Max(FieldName) is made. For SQLServer and SQL Anywhere you can code a call to the variable @@identity to retrieve the last auto increment value. The ASTA server then uses this value, or the prime key fields value to fetch all the fields as specified in the RefetchOnInsert property. The server SQL is executed and when it all is completed, the RefetchOnInsert values are streamed from the ASTA server and matched up to the appropriate rows in the TAstaClientDataSet.
Related Topics
ASTA
SQL Generation
Oracle
Sequence
SendMasterDetailAutoIncTransaction