Subject Re: [IBO] TIB_Cursor
Author Markus Ostenried
At 13:17 Monday, 23.02.2004 +0000, Michael Vilhelmsen wrote:
>I'm about to change some TIBOQuery to TIB_Cursor.
>On some of my TIBOQuery comp. I have some calculated fields.
>Can I do this on a TIB_Cursor as well ?
yes.

>And maybe how to ?
You have to define the calculated fields in the property
TIB_Cursor.CalculatedFields. Its a stringlist in which you write something
like

MYINTCOLUMN INTEGER NOT NULL
MYSTRCOLUMN VARCHAR ( 50 )

Then just write the appropriate code in the OnCalculateFields event,
somthing like

procedure TM_ResAvailWiz.Qry_RA_CategoryCalculateField( Sender: TIB_Statement;
ARow: TIB_Row;
AField: TIB_Column );
begin
if (AField.FieldName = 'MYINTCOLUMN') then begin
AField.AsInteger := 42;
end else
if (AField.FieldName = 'MYSTRCOLUMN') then begin
AField.AsString := Concat( ARow.ByName('SOME_OTHER_FIELD').AsString),
' - bla' );
end;
end;

Read in the IBO help file about OnCalculateFields.
Note that TIB_Cursor is unbuffered, therefore a calculated field has to be
calculated each time you access it. In TIB_Query the value of a calculated
field will be stored in the buffer of the row.

HTH,
Markus