Page 1 of 1

How to handle serial(autoinc) fields with a grid?

Posted: Wed 26 Aug 2009 18:35
by snorkel
Hi,
I used to use the components from Microolap, and they seemed to handle serial(autoinc) fields automatically when used in a grid such as the one from DevExpress.

Currently if I have a table opened and I insert a row I have to refresh the whole dataset to get the autoinc number to populate.

Thanks,

Snorkel

Posted: Thu 27 Aug 2009 07:28
by Plash
You should set the DMLRefresh option of TPgQuery to True. In this case PgDAC generates INSERT statement with the RETURNING clause to get back inserted field values.

Posted: Thu 27 Aug 2009 14:16
by snorkel
Thanks for the info.
Does using returning work on all versions of PostgreSQL?
I thought that was a newer feature of 8.3 or 8.4.

Later,

Snorkel

Posted: Fri 28 Aug 2009 08:48
by Plash
RETURNING is supported starting with PostgreSQL 8.3. But there is no other way to get back a value generated in the database.

Posted: Fri 11 Sep 2009 18:52
by snorkel
Plash wrote:RETURNING is supported starting with PostgreSQL 8.3. But there is no other way to get back a value generated in the database.
I looked in the docs and it seems 8.2 also supports it:

http://www.postgresql.org/docs/8.2/inte ... nsert.html

Posted: Mon 14 Sep 2009 07:40
by Plash
You are right, RETURNING is supported starting with PostgreSQL 8.2.