1
votes

I have migrated an AnyDAC app to FireDAC and I can't get to work its Autoinc fields.

The ID field (primary key) has been defined on Postgre SQL as default to nextval('llistapanelspuzzle_id_seq'::regclass), BIGSERIAL, so the server automatically sets its values.

The column was recognized by AnyDAC as an TAutoincField and worked correctly, but when I now open that table on FireDAC it fails saying that the field found is a TLargeIntField. I change the persistent field to a TLargeIntField, but now when inserting records on Delphi, I don't get the new values from the server, it leaves the dataset with a 0 value, and when I add a second record it raises a Key Violation (two records with a 0 value on its primary key).

Do you know how to define AutoInc fields on FireDAC - PostgreSQL, when they are being recognized as LargeInt fields ?.

Update: I have added ID to the UpdateOptions.AutoIncFields, but it doesn't seem to have changed anything.

Thank you.

1
Hi Marc. I'm not a PostGreSQL user myself but have you checked out this page ?MartynA
How do you insert a record? I guess you don't use an explicit INSERT SQL query?Olivier
Hi @MartynA. Yes, thank you, this is what I was reading when I updated the post saying that I tried adding the column to the UpdateOptions.AutoIncFields. I guess I missed an step, so I'll keep trying the Manual Specifiying section.Marc Guillot
Hi @Olivier No, I have a TFDQuery with a SELECT * FROM MyTABLE, where I do several MyQuery.Apend and MyQuery.Post.Marc Guillot
Try with query fields editor recreate persistent fields, at least autoinc fieldBranko

1 Answers

0
votes

Looks like you have to activate the ExtendedMetada flag on the FDConnection in order for FireDAC to recognize automatically the PostgreSQL Autoinc columns.

Now it works correctly.