peculiar problem when appending record - firedac & advantage

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

peculiar problem when appending record - firedac & advantage

Postby Azazaz » Tue Feb 09, 2016 9:31 am

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.
Azazaz
BCBJ Guru
BCBJ Guru
 
Posts: 105
Joined: Wed Sep 26, 2012 9:08 am

Re: peculiar problem when appending record - firedac & advan

Postby minas » Tue Feb 09, 2016 2:25 pm

just call FFDTable->Last() right after Post()
-
User avatar
minas
BCBJ Guru
BCBJ Guru
 
Posts: 196
Joined: Sat Jul 10, 2004 6:09 am
Location: Greece

Re: peculiar problem when appending record - firedac & advan

Postby Azazaz » Tue Feb 09, 2016 9:34 pm

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.
Azazaz
BCBJ Guru
BCBJ Guru
 
Posts: 105
Joined: Wed Sep 26, 2012 9:08 am


Return to Technical

Who is online

Users browsing this forum: No registered users and 6 guests

cron