Subject FOR SELECT .. DO .. UPDATE is slow
Author clementdoss
Hi,

I'm using WI-V6.3.0.436 Firebird 1.5

I am building a small stored procedure, and I need to update some
records (7701). And I believe it's taking too much time. 10+ minutes.
I don't know if this is the best way.
This is the code I'm using:

OLDBalance = 0;

FOR SELECT int_mov_id,
mny_credit,
mny_debit,
mny_balance
from TB_MOV
where BLN_CALC = 'N'
into :MovID , :Credit, :Debit, :Balance
DO BEGIN
NewBalance = OldBalance + Credit - Debit;

update TB_MOV set
mny_balance = :NewBalance,
bln_calc = 'S'
where int_mov_id = :MovID;

OldBalance = NewBalance;
END;


I have commented out the "update TB_MOV ..." code out of it. And
it's still very slow, so I guess that the update is not the issue,
but this FOR SELECT is slow. Am I correct? Can a FOR SELECT be that
slow?
What would be the correct way to implement this code in FB?

TIA,
Clément