Subject Re: [ib-support] cursors in sp??
Author Regina Phandu
Lucas,

the sp that you gave me works well, but it only works for 1 record. what i
need is a cursors, i believe.
and i also need to update the quantity of the product. not only returns
values/display the values. so, i guess, i need cursors and updating the
product qty itself.
I tried so hard with cursors, but i still can't make it work.

Thx!

Regina Phandu

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


>
> Regina,
>
> you can write a stored procedure like:
>
> SET TERM #;
> CREATE PROCEDURE SEL_PRODUCTQTY
> RETURNS (
> PROD_CODE INTEGER,
> QTY INTEGER
> )
> AS
> declare variable PRODQTY INTEGER;
> declare variable SUMQTY INTEGER;
> BEGIN
> FOR SELECT PROD_CODE, QTY FROM PRODUKT
> INTO :PROD_CODE, :PRODQTY
> DO BEGIN
> SELECT SUM ( QTY ) FROM TRANSAKTION
> WHERE PROD_CODE = :PROD_CODE INTO :SUMQTY;
>
> IF ( SUMQTY IS NULL ) THEN SUMQTY = 0;
>
> QTY = PRODQTY - SUMQTY;
> SUSPEND;
> END
> END#
> SET TERM ;#
>
> Then you can select the result with a Query by:
>
> SELECT * FROM SEL_PRODUCTQTY;
>
>
>
> Hth
>
> 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/
>
>
>