Subject Re: [IBO] How can I load a query in memory?
Author Lucas Franzen
Hello,


> I think in some solutions:
>
> 1) Before begin the bucle, I can load this records (not all the
> table) in a StringList or similar, and in the bucle, search in the
> StringList (this is in memory). I think it's no the best method. So
> manual !!!
>
> 2) Write an IF LOCATE line inside the bucle. I'll test it but is
> very slowly (the search is with 2 fields). I have test to write an
> Qry.readonly:=true
> Qry.fetchall;
> Qry.prepare;
> ...
>
> to increase speed (the result is the same...)
>
> 3) Call to an stored procedure with the select (it uses the primary
> key index). Slowly. More similar to (2)
>
> Exists in IBO an alternative to 2) or 3) and load the query in
> memory.

It won't be too much coding to set up an object which will save these
informations for you and storing all the objects you have in a
TObjectList (which has the big advantage compared to a regular TList
that you don't have to free the stored objects on your own -
clearing/freeing an ObjectList will do that automatically).

Searching the ObjectList for a certain object is "lightning fast"; and
if you need detailed information of the records you've got in the
object(s), it shouldn't be too difficult to set up the appropriate
methods (kind of a Locate) for doing so, either (ie setting up a select
SQL for the records you need).

(I do have complete master-detail-subdetail information stored in
TObjectLists - loading is done with a TIB_Cursor and when the user's
changing data and wants to save it there are just TIB_DSQL statements
for INSERTING/UPDATING - the objects do know on their own what action
they've got to perform.)

Maybe this is an option for you?

Regards
Luc.