I seem to have 2 problems:
1) Firedac recognizing:
Firedac sometimes does not seem recognize auto inc fields. What are the *exact* terms for recognizing these fields? (and where can I find the source code for this).
The tables are all set up *exactly* the same way: primary key + generator + trigger before insert (new.id = select next value for ...)
Is it possible that - when I seem to have lost some system check constraint triggers - Firedac does not recognize the fields?
What could be other reasons.
2) Firedac incrementing twice
When I have a TFDQuery with a TFDAutoIncField setup like this:
- Field.GeneratorName := xxx;
- Field.IdentityInsert := True;
- Qry.UpdateOptions.FetchGeneratorsPoint := gpImmediate; // a.s.a.p. clientside generator filling
Then after appending a record the ID field is incremented twice! Of course the trigger is called within Firebird itself.
It seems Firedac makes a call to this trigger again??
Regards, Eric Langedijk
Vote for best question.
Score: 0
# Vote: 0
Date Posted: 10-Jan-2015, at 5:20 AM EST
From: eric langedijk
Re: Difficult problems with Firebird Generators, Triggers, F
Not found the "recognizing" code yet.
Addition. When I create my own "runtime-persistent" dataset descendant and just create a TFDAutoIncField everything goes well.
Firedac does _not_ complain about some field type mismatch.
That is when I implement my own "recognizing code" (look for specific generator, look for specific trigger) with the tool that creates my datasets.
{code}procedure TRekening.CreatePersistentFields; // descendant of TFDQuery
begin
FldID := TFDAutoIncField.Create(Self);
with FldID do begin
FieldName := fn_ID;
Dataset := Self;
ProviderFlags := [pfInWhere,pfInKey];
Origin := 'ID';
GeneratorName := 'GEN_REKENING';
IdentityInsert := True; // a.s.a.p. clientside generator filling
FieldTag.ExtendedOrigin := 'REKENING.ID';
FieldTag.ExtendedOptions := [efoExcludeUserEdit];
end;
//...
UpdateOptions.FetchGeneratorsPoint := gpImmediate; // a.s.a.p. clientside generator filling
SQL.Text := string(sql_persistent); // load hard coded constant
{code}
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 12-Jan-2015, at 11:12 PM EST
From: eric langedijk
Re: Difficult problems with Firebird Generators, Triggers, F
> What are the *exact* terms for recognizing these fields? (and where can I find the source code for this).
http://docwiki.embarcadero.com/RADStudio/XE7/en/Auto-Incremental_Fields_(FireDAC)#Automatic_Recognition
The source code is FireDAC.Phys.IBMeta, look there for a mkResultSetFields and corresponding SQL query.
--
With best regards,
Dmitry Arefiev / FireDAC Architect
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 10-Jan-2015, at 9:02 PM EST
From: Dmitry Arefiev
Re: Difficult problems with Firebird Generators, Triggers, F
eric langedijk wrote:
> Then after appending a record the ID field is incremented twice! Of
> course the trigger is called within Firebird itself. It seems
> Firedac makes a call to this trigger again??
The trigger in FireBird should not increment when the field is not
NULL, which is the case when the field is filled by FireDac in advance.
--
Uwe Raabe
Embarcadero MVP