Subject INTO clause is execute before SELECT
Author kokok_kokok
I use FB 2.0 and in a SP I get strange results. It really seems a FB bug:


select :acumunits + units,
(:acumunits*:acumprice+price*units)/(:acumunits+units)
from inventorytable
where inventoryid=:inventoryid
into :acumunits, :acumprice;


I am using :acumunits in both the SELECT and INTO clause, this seems
to confuse Firebird.

The calculation "(:acumunits*:acumprice+price*units)/(:acumunits+units)"
is being executed after the INTO :acumunits part, therefore, acumunits
already contains the "old" value.

In the other hand, if I use


select :acumunits + units,
(:acumunits*:acumprice+price*units)/(:acumunits+units)
from inventorytable
where inventoryid=:inventoryid
into :tmp_acumunits, :tmp_acumprice;

everything works fine.


I have been speaking with Martijn Tonies, from Upscene, and he has
confirmed this problem also.

I have solved it using temporal variables, but I wanted to report this
possible bug.

Thanks