Page 1 of 1

peculiar problem when appending record - firedac & advantage

PostPosted: Tue Feb 09, 2016 9:31 am
by Azazaz
I have a routine that, among other things, sometimes appends a record to a table. The first field in the table is an autoinc field. In the past, I have always been able to retrieve that autoinc integer value after posting the record.

But using the FireDAC component, i.e., a TFDTable, I am unable to do it.

Here's the code:

FFDTable->Append();
FFDTable->FieldByName("Status")->AsInteger = 1;
FFDTable->Post();
currRI = FFDTable->Fields->Fields[0]->AsInteger; // always returning zero
currRI = FFDTable->FieldByName("RI")->AsInteger; // also always returning zero


In a brand new table, the autoinc value would be 1. I have tried this with several records, e.g., 1, 2, 3, and so on, but the value returned is always zero.

Is this a bug? Anyone know how to get around this?

Thanks.

Re: peculiar problem when appending record - firedac & advan

PostPosted: Tue Feb 09, 2016 2:25 pm
by minas
just call FFDTable->Last() right after Post()

Re: peculiar problem when appending record - firedac & advan

PostPosted: Tue Feb 09, 2016 9:34 pm
by Azazaz
I've never had to do that before, but okay. I guess.

It's not the first time FireDAC's behavior has mystified me; probably won't be the last.

Thanks. I'll try it.