Thread: Recognation of AutoInc field for Firebird 2.5
|
Replies:
6
-
Last Post:
Jan 25, 2017 4:00 AM
Last Post By: Norbert Meier
|
|
|
Posts:
19
Registered:
11/26/01
|
|
Hello,
I've a Firebird database with a table that include an "ID" column that is the Primary key column and it's value is generated by a before insert Trigger by using a Generator:
FireDAC (TFDtable) does not recognize this column as an autoinc field, although I set
ExtendedMetaData = True
I looked at:
[http://docwiki.embarcadero.com/RADStudio/Berlin/en/Auto-Incremental_Fields_(FireDAC)]
[https://forums.embarcadero.com/thread.jspa?messageID=868487]
but I must use
FDTable1.UpdateOptions.AutoIncFields := 'ID';
What could be the reason why FireDAC does not recognize the column as AutoInc field?
Thanks
Norbert
|
|
|
Posts:
1,406
Registered:
12/7/03
|
|
1) Check that fiMeta is included into FetchOptions.Items
2) Please provide DDL for your table and trigger
--
With best regards,
Dmitry
|
|
|
|
Posts:
19
Registered:
11/26/01
|
|
Dmitry,
I've uploaded a small demo application in attachments
See
[https://forums.embarcadero.com/thread.jspa?messageID=874213󕛥]
The FetchOptions.Items include fiMeta.
Regards
Norbert
|
|
|
|
Posts:
1,406
Registered:
12/7/03
|
|
On +DX10.1 source base your test application works correctly:
* ID field is recognized as TLargeintField. This is correct because ID is defined as BIGINT and it does not fit into TAutoIncField.
* ID field is setup correctly, so FireDAC automatically refetches new ID value after posting a new record.
If you see different behavior, then please specify your exact RAD Studio version. And I will check what and when was changed in FireDAC in this area.
--
With best regards,
Dmitry
|
|
|
|
Posts:
19
Registered:
11/26/01
|
|
I'm currently using XE6 for that Project..
If I don't set AutoIncFields:
After calling Append:
prjInfTemp1.FieldByName('ID').IsNull is True
prjInfTemp1.FieldByName('ID').AsLArgeInt is 0
Post fires exception: Add record failed: Field 'ID' must have a value
If I set AutoIncFields
After calling Append:
prjInfTemp1.FieldByName('ID').IsNull is False
prjInfTemp1.FieldByName('ID').AsLArgeInt is -1
Post works fine in this case.
PS: The two assert lines regarding "ID" is Null or = -1 fail in the demo app, if I don't set AutoIncFields!
Regards
Norbert
|
|
|
|
Posts:
1,406
Registered:
12/7/03
|
|
That means, that ID field is not recognized as auto-inc field.
There were multiple changes in this area after XE6, so it is not simple to provide patch.
So, setting AutoIncFields is a correct workaround.
--
With best regards,
Dmitry
|
|
|
|
Posts:
19
Registered:
11/26/01
|
|
Thanks Dmitry,
I'll use the workaroung to fix this issue.
Best Regards
Norbert
|
|
|
|
Legend
|
|
Helpful Answer
(5 pts)
|
|
Correct Answer
(10 pts)
|
|
Connect with Us