Subject Re: [ib-support] cursors in sp??
Author Regina Phandu
Yes, i understand that I have to delete the record in t_transaction.
actually, this is just a piece of my work. I still need to create another
process that using values in table transaction.
After all my process done, then, i'll delete all records in table
transaction. Also, i don't need to return values.
So, I removed the return values and I declare the variables. I tested the
procedure and it works just like i need it.

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)
from t_transaction
where t_prod_code = :prod_code
into :v_sum_qty;

if (v_sum_qty is null) then v_sum_qty = 0;

vqty = v_qty - v_sum_qty;

if (v_sum_qty > 0) then
begin
update tm_pos_product set qty = :vqty
where prod_code = :prod_code;
end

end
end#
set term;#

Thanks a lot!

Regina Phandu

----- Original Message -----
From: "Lucas Franzen" <luc@...>
To: <ib-support@yahoogroups.com>
Sent: Thursday, October 03, 2002 3:59 AM
Subject: Re: [ib-support] cursors in sp??


>
>
> Regina Phandu schrieb:
> >
> > Many thanks to Lucas and Martijn!!
> >
> > I removed the Suspend and the procedure works well.
>
> But this way you're returning just the prodcode and qty for the last
> record that was found in the FOR SELECT loop.
>
> What's the sense of this?
>
> And if you don't delete the entries in the t_transaction table and
> execute the procedure again you'll diminish the values for qty within
> tm_pos_product once again....
>
> Luc.
>
>
> 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/
>
>
>