Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TFDConnection.GetLastAutoGenValue in a dataset POST process


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Aug 29, 2017 12:52 PM Last Post By: Maxime Bonin
Maxime Bonin

Posts: 61
Registered: 1/23/17
TFDConnection.GetLastAutoGenValue in a dataset POST process  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 28, 2017 6:48 AM
Hello all !

i'm working with Delphi XE8 and I'm connected to Microsoft SQL Server 2014 thru FireDAC

My question concerns the 'GetLastAutoGenValue' method of the TFDConnection :

Context :

I am posting a new record in a table, in the meantime I'm logging the transaction in a different table. In order to do so, I have to get the ID of the new record being posted (so I am in the AfterInternalPost of TDataset.Post process)

With Advantage Database Server, there is a method called AdsGetField(FieldName, optNONE) that retrieves the value of the ID being posted before the transaction is totally commited to the database.

In order to copy this mechanism, I first tentatively used :
  Connection.GetLastAutoGenValue(''); 

without the fieldname : it returns ID value all the time, _but not the first time it is being use

Then I wised up and tried this :
  Connection.GetLastAutoGenValue(mIdFieldName); 

But with this, I get an EFDException with message [FireDAC][Phys] -303. Capability is not supported

Is it because I am too soon in the posting process or is there a propriety I need to set ?

Thanks for your help !

Edited by: Maxime Bonin on Aug 28, 2017 10:52 AM
Maxime Bonin

Posts: 61
Registered: 1/23/17
Re: TFDConnection.GetLastAutoGenValue in a dataset POST process  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 29, 2017 12:52 PM   in response to: Maxime Bonin in response to: Maxime Bonin
I moved the place GetLastAutoGenValue.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02