Subject RE: [IBO] Storing query results in variables
Author Jason Wharton
If you use a buffered query then it will be a very fancy list for you
because essentially the internal buffer of the query is a specialized linked
list. It's very memory efficient, though not as much as yours appears to
be.

If you want to maintain your own list then I suggest you use the TIB_Cursor
component because it is just unidirectional.

MyCursor.APIFirst;
while not MyCursor.Eof do
begin

> linked_list^.id := MyCursor.Fields.Values['HACID'];
> linked_list := lined_list^.next;

MyCursor.APINext;
end;


For better performance I suggest you do not use a field by name lookup, but
instead use a local variable of type TIB_Column like this:

var
MyCol: TIB_Column;
begin
MyCursor.Prepare;
MyCol := MyCursor.FieldByName('HACID');
MyCursor.APIFirst;
while not MyCursor.Eof do
begin

> linked_list^.id := MyCol.Value;
> linked_list := lined_list^.next;

MyCursor.APINext;
end;
end;


Of course you will need to do more to manage your linked list but this
should give you a starter template to work from. If you need more columns,
just add more local variable.

I also showed you the API methods that will greatly increase your
performance if you do not need events triggered like DataChange,
StateChange, OnCalculateFields, etc. You also should not have BLOB or ARRAY
columns if you are using API based methods. If you need any of this stuff,
just remove the 'API' prefix and use the normal methods. This just gives
you an added boost of performance.

Regards,
Jason Wharton
www.ibobjects.com

Don't forget the sale on upgrades going on right now.
Hurry over to http://community.ibobjects.com and get yours now.


> -----Original Message-----
> From: yaedos2000 [mailto:yaedos2000@...]
> Sent: Wednesday, November 10, 2004 7:09 AM
> To: IBObjects@yahoogroups.com
> Subject: [IBO] Storing query results in variables
>
>
>
>
> Hi,
>
> Can the result of a TIB_Query be stored straight to a variable? I'm
> using the query SELECT HACID FROM HACS to get a list of ID numbers,
> and I can store the first item with the expression:
>
> linked_list^.id := Query.Fields.Values['HACID'];
> linked_list := lined_list^.next;
>
> I'm using a linked list to store the ID numbers, as the number of
> data items is not known at design time. As the above expression only
> obtains the first ID number, how would any other ID numbers be
> obtained?
>
>
>
>
>
> ------------------------ Yahoo! Groups Sponsor
> --------------------~-->
> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
> Now with Pop-Up Blocker. Get it for free!
> http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/PhFolB/TM
> --------------------------------------------------------------
> ------~->
>
> ______________________________________________________________
> _____________
> IB Objects - direct, complete, custom connectivity to
> Firebird or InterBase
> without the need for BDE, ODBC or any other layer.
> ______________________________________________________________
> _____________
> http://www.ibobjects.com - your IBO community resource for
> Tech Info papers,
> keyword-searchable FAQ, community code contributions and more
> !
> Yahoo! Groups Links
>
>
>
>
>
>
>
>