Watch, Follow, &
Connect with Us

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


Welcome, Guest
Guest Settings
Help

Thread: Change in behaviour of Getfielddata


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


Permlink Replies: 1 - Last Post: Nov 5, 2017 2:37 AM Last Post By: Dmitry Arefiev Threads: [ Previous | Next ]
Tom Byrnes

Posts: 4
Registered: 4/18/09
Change in behaviour of Getfielddata  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 4, 2017 4:29 PM
I have a TFDtable descendant which adds a number of currency fields in the InternalOpen. i.e. these fields do not exist in the underlying DB table.
They are added with a fieldkind of fkData (though it makes no difference if I use fkInternalCalc).

The TFDtable descendant overrides the GetFieldData (and SetFieldData) methods in the following general manner:
function TMyTable.GetFieldData(Field: TField; var Buffer: TValueBuffer): Boolean;
begin
  PDouble(Buffer)^ := someField.Value * someOthervariable;
  ......
end;


And SetFieldData does more or less the reverse.

This was working fine in XE6, but having just upgraded to Tokyo, it now thrwos an exception as the Buffer is nil.
Is there a way of forcing FireDAC to allocate a buffer for these type of fields, or do I need to consider a different approach to populating these fields.

Possible fix: I have gotten the GetFieldData part to work by simply adding the line:
    SetLength(Buffer, SizeOf(Double));


Buffer is a var parameter and is just an array of bytes, so this shoudl be a legitimate move, but I would still like some reassurance on this. Thanks.

Edited by: Tom Byrnes on Nov 4, 2017 5:05 PM
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Change in behaviour of Getfielddata  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 5, 2017 2:37 AM   in response to: Tom Byrnes in response to: Tom Byrnes
Use fkInternalCalc fields and assign them values in OnCalcFields event.

--
With best regards,
Dmitry
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02