We cannot reproduce the specified problem with RETURNING clause in batch operations. Please compose a small test project to demonstrate it and send us via the contact form at our site: https://www.devart.com/company/contactform.html. In the sample, also include the script for creating the XTABLE table.

Hmm, I cannot reproduce the AV in a simple test project. However, I still have an issue. Calling Execute(2) inserts the rows into the database, that's fine. But... The query object does not return any rows. RecordCount is zero after calling Execute(2).

I think I need to call some other method instead of Execute() to get any returned rows (just like with non-batch queries). Is that correct ? Open() does not seem to support any parameters for batch operations.

I used the following code (just create a simple table 'xtable' with two varchar fields)

The INSERT SQL command only inserts rows to the table on the server. Therefore, the TPgQuery.Execute call for such an SQL query does not return the inserted rows to the dataset. This is correct behavior. More details about INSERT SQL command in PostgreSQL documentation: https://www.postgresql.org/docs/current ... nsert.html

If you create a TPgQuery with an SQL text like "Insert Into XTable (A, B) Values (:A, :B) RETURNING A, B" and if you call OPEN() on that TPgQuery, it definitely returns the A and B fields for the new records. It adds the rows on the server, and then returns the desired fields. You can then navigate through those records, just like a SELECT query.

This can be used to (for example) return SERIAL values that have been added.

I actually use this functionality in PgDac.

My question is : This works perfectly for normal (non-batch) queries. You have to call Open() instead of ExecSQL(). For batch-queries, I think there is only the Execute(nr) method, no Open() method there.