Subject [ib-support] Room for optimization? (CORRECTED SP)
Author Tobias Giesen
Hello,

I found I hadn't translated all field names correctly,
so here's the stored procedure again:

CREATE PROCEDURE Recalculate(FromLine INTEGER)
AS
declare variable LineNum Integer;
declare variable maxLineNum Integer;
declare variable currentid Integer;
declare variable thisid Integer;
declare variable Amount decimal(17,2);
declare variable IDBalance decimal(17,2);
declare variable BankBalance decimal(17,2);
BEGIN
BankBalance=0;
FOR SELECT Amount,LineNum
FROM BookLines
ORDER BY LineNum
INTO :Amount,:LineNum
DO BEGIN
BankBalance = BankBalance + Amount;
UPDATE BookLines
SET BankBalance = :BankBalance
WHERE LineNum= :LineNum;
END

maxLineNum=LineNum;

IDBalance=0;
currentid=0;
FOR SELECT Amount,ID,LineNum
FROM BookLines
ORDER BY ID,LineNum
INTO :Amount,:thisid,:LineNum
DO BEGIN
if (thisid>currentid) then begin
IDBalance=0;
currentid=thisid;
end
IDBalance=IDBalance+Amount;
UPDATE BookLines
SET IDBalance = :IDBalance
WHERE LineNum= :LineNum;
END
END ^

-----------------------

Thanks.

Tobias Giesen



To unsubscribe from this group, send an email to:
ib-support-unsubscribe@egroups.com



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