EhLib
ContentsIndexHome
PreviousUpNext
Working with AutoIncrement fields

TMemTableEh has an AutoIncrement property with InitValue and Step subproperties to work with fields which values are generated by automatic sequence numbers. For such fields property TField.AutoGenerateValue mast be arAutoInc. Values for such fields are generated automatically using internal counter when the new record is appeared in the internal array. Initial value of the counter is assigned by the TMemTableEh.InitValue property. After inserting new record, a value of the counter increases on the number given by the TMemTableEh.Step property. 

If TMemTableEh is connected to DataDriver then usually values of such fields are generated by the server. To cause TMemTableEh be able to get values of fields generated by the server, it is recommended to use TMemTableEh and TSQLDataDriver (or inherited from it) as follow: 

Set InitValue property and Step property to -1. Values of AutoIncrement fields will have negative values before sending the new record to the server. 

Add parameters in TSQLDataDriver.SpecParams property to make SQLDataDriver be able to get values of AutoIncrement fields generated by the server. List of parameters in TSQLDataDriver.SpecParams depends on the type of Server and will be described later. After updates are applied and record new writes to the server, SQLDataDriver will request new value of the counter from server and assign it to the AutoIncrement field on the client.

Copyright (c) 1998-2013. All rights reserved.
What do you think about this topic? Send feedback!