Subject Re: [IBO] aggregate fields? Persistant fields?
Author James
Hi Paul

Paul Vinkenoog wrote:

> Fields are "persistent" from the moment the dataset is prepared until
> it is unprepared. What I often do (in C++ Builder) is the following.
> Suppose I have a query qryPersons returning two columns: Name and
> Address. I don't want to use FieldByName all the time and in loops it
> could even slow things down. So I make an AfterPrepare handler for the
> query with this code (or calling a function with this code):
>
> ...
> colName = qryPersons->FieldByName( "Name" );
> colAddr = qryPersons->FieldByName( "Address" );
> ...

Iam following this thread to learn more about IBO. I am surprise to see
something like what you have done here, but it sounds great =). May I
know what is the advantage of using the FieldByName over the
colName=qryPersons->FieldByName("name");? You mention that in that in
loops this could make ther performance better.

>
> ...colName and colAddr being TIB_Column* fields of the Form (or global
> variables, depending on the situation).
>
> Upon unprepare, they should be reset to NULL (nil in Delphi). Actually
> I use the same function for that, called with a parameter from the
> AfterPrepare handler.
>
> Now if I need to access those fields in my code I just do:
>
> HisName = colName->AsString;
> colAddr->AsString = "27 Penny Lane";

am I right to say that if I'll be using this kind of technique I have to
assign all the fields that I will be using in afterprepare event? and
declare a TIB_Column variable for each field that I will be using?


Regards,
james