Subject RE: [IBO] Walking entire dataset
Author John Tomaselli
Bob, here is a sp to follow as an example.
HTH
John
begin


for select
CONTRACT_DETAIL_ID,
QUANTITY,
SHIPPED_TOTAL from
A_CONTRACT_DETAIL
WHERE not(QUANTITY is null) and (contract_detail_id > 5874)
into
:VCONTRACT_DETAIL_ID,
:VQUANTITY,
:VSHIPPED_TOTAL_HOLD

do begin
select
sum(QUANTITY_SHIPPED)
from A_SHIPPING_SCHEDULE

where CONTRACT_DETAIL_ID = :vCONTRACT_DETAIL_ID

into :vQTY_SHIPPED ;


if (:vQTY_SHIPPED is not null) then
update
A_CONTRACT_DETAIL set
SHIPPED_TOTAL = :vQTY_SHIPPED
where CONTRACT_DETAIL_ID = :vCONTRACT_DETAIL_ID ;
end
suspend;

end

-----Original Message-----
From: news@... [mailto:news@...]On Behalf Of Bob
Sent: Thursday, April 18, 2002 1:41 PM
To: IBObjects@yahoogroups.com
Subject: [IBO] Walking entire dataset


I'm looking for some advice re: how to search an entire dataset of invoices
and perform some calculations. I know I can use a TIB_Query to fetch the
invoice table sorted by invoice date, and then walk through it (using
qrInvoice.Next) building my subtotals for each day's sales as I go, and
keeping track of when the date changes, something like this:

with qrInvoice do begin
Open;
First;
while not eof do begin
if LastDate <> qrInvoice['INV_DATE'] then begin
DisplaySubTotal(LastDate, SubTotal);
SubTotal := qrInvoice['AMOUNT'];
LastDate := qrInvoice['INV_DATE'];
end else
SubTotal := SubTotal + qrInvoice['AMOUNT'];
Next;
end;
end;

My question is this: Is there a smarter (read "faster") way to do this? I
fear that this might take a long time to execute. I'm still figuring out
IBObjects and have also considered Filters or SQLWhereItems to get this done
but don't know what's appropriate. What's the best approach?

Thanks.

Bob.




___________________________________________________________________________
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 !

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/