Subject Re: [ib-support] cursors in sp??
Author Martijn Tonies
> >set term #;
> >create procedure sp_end_of_day_2
> >
> >as
> > declare variable v_qty float;
> > declare variable v_sum_qty float;
> > declare variable vqty float;
> > declare variable prod_code integer;
> >begin
> > for select prod_code, qty
> > from tm_pos_product
> > into :prod_code, :v_qty
> > do
> > begin
> > select sum(t_qty) <---- A
> > from t_transaction
> > where t_prod_code = :prod_code
> > into :v_sum_qty;

--8<--

> Perhaps a simpler way to do it (without casting and re-casting) would be
this:

And what about:

select sum(t_qty)
from t_transaction
where t_prod_code = :prod_code
and t_qty is not null



With regards,

Martijn Tonies
InterBase Workbench - the developer tool for InterBase
http://www.upscene.com

Firebird Workbench - the developer tool for Firebird
http://www.upscene.com

Upscene Productions
http://www.upscene.com

"This is an object-oriented system.
If we change anything, the users object."
--8<--

> declare variable tr_qty float;
> ...
> do
> begin
> v_sum_qty = 0;
>
> for select t_qty
> from t_transaction
> where t_prod_code = :prod_code
> into :tr_qty do
> begin
> if tr_qty is not null then
> v_sum_qty = v_sum_qty + tr_qty;
> end
> vqty = v_qty - v_sum_qty;
> ...
>