Subject Re: [IBO] aggregate fields? Persistant fields?
Author Paul Vinkenoog
Hello,

> I am new to IBO and would like to know if there is an elegant
> solution to aggregate fields in IBO?

You can just use them in your queries (optionally giving them an SQL
alias) and they wind up as columns in the dataset. Nothing complicated
about it!

> How about persistant fields? I don't like to refer to fields in
> code with FieldByName.

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" );
...

...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";

etc.


Greetings,
Paul Vinkenoog

(persistent IBO user)