Subject | Re: [IBO] Walking entire dataset |
---|---|
Author | Jason Wharton |
Post date | 2002-04-18T22:17:03Z |
For sure there is, write a query that will do it for you.
If a query won't do it then write a stored procedure you pass some
parameters to.
Rule of thumb, let the server do as much of the work as is possible.
HTH,
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com
If a query won't do it then write a stored procedure you pass some
parameters to.
Rule of thumb, let the server do as much of the work as is possible.
HTH,
Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com
----- Original Message -----
From: "Bob" <rcmiszuk@...>
Newsgroups: egroups.ibobjects
To: <IBObjects@yahoogroups.com>
Sent: Thursday, April 18, 2002 10:40 AM
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.