For performance, I'd like to use either TUniLoader or a batch operation as described in 4.9 of the manual (array parameters).
However, for each record inserted I need its autoincrement ID as it will be used for reference in another table. Currently I iterate over setting parameters, executing and memorizing the LastInsertID which is not really performant.
How can I get the IDs of the inserted records with either TUniLoader or after an Execute(1000) statement?
Kinds regards,
Thomas
Batch Insert: How to get id's of inserted records?
Re: Batch Insert: How to get id's of inserted records?
Please specify what database you select when using our product. What do you think what result the Execute(1000) method should return?
Re: Batch Insert: How to get id's of inserted records?
Currently, I'm using an sqlite database, but I think this also applies to any other provider supporting the lastinsertid property.
After running Execute(1000) (or whatever number), I would expect to gain access to an array of all inserted IDs, analog to the ParamByName('xxx')[n] array which provides the data to be inserted. In other words, when using the Batch function, LastInsertID should be an array of INT64 instead of just an INT64.
After running Execute(1000) (or whatever number), I would expect to gain access to an array of all inserted IDs, analog to the ParamByName('xxx')[n] array which provides the data to be inserted. In other words, when using the Batch function, LastInsertID should be an array of INT64 instead of just an INT64.
Re: Batch Insert: How to get id's of inserted records?
Unfortunately, in this question, we are limited by the possibilities of SQLite, which provides only the last_insert_rowid function (http://www.sqlite.org/c3ref/last_insert_rowid.html) to return values of interest to you. This function allows you to return a value for only one inserted record. If there is the necessary support from the server in the database (for example, Oracle DB), then we return the autoincrement values as an array (this is the behavior that is implemented in our ODAC product).
Re: Batch Insert: How to get id's of inserted records?
Ok, I understand. Thanks for your explanation.
Re: Batch Insert: How to get id's of inserted records?
Thank you for your interest to our products. Feel free to contact us if you have any further
questions about UniDAC.
questions about UniDAC.