Hi,
I'm using a PgQuery -> DataSetProvider -> ClientDataSet -> PgDataSource "chain" to manage the data.
It's all ok, but...
If I have a table with a field (the primary key) defined as serial data type (and in the query properties the key and the sequence name are correctly defined), the first record you insert is ok (and it takes, for example, the id value of 1), but when you post a second one you receive an error message of "duplicate key" or similar instead of the id 2.
On every post I call a StartTransaction, ApplyUpdates(0), Commit.
If I use only PgQuery -> PgDataSource is all ok.
Is there something I'm doing wrong?
Thanks in advance.
Sergio
ClientDataSet and serial fields
TClientDataSet cannot refresh value of ID field. When it is filled in the TPgQuery component with a value from the sequence, in TClientDataSet the field keeps NULL value.
Because you have set the KeyFields property, you cannot insert two records with the same value (NULL) of ID field into the TClientDataSet component.
You should call the Refresh method of TClientDataSet each time after ApplyUpdates for the component read new values of ID field.
Because you have set the KeyFields property, you cannot insert two records with the same value (NULL) of ID field into the TClientDataSet component.
You should call the Refresh method of TClientDataSet each time after ApplyUpdates for the component read new values of ID field.