Subject Re: [ib-support] cursors in sp??
Author Martijn Tonies
Regina,

Lucas gave you a select-able stored procedure. If you want to execute
it and loop over rows, remove the SUSPEND thing.
A FOR SELECT DO is a loop.


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."

> 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/
> >
> >
> >
>
>
>
> 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/
>
>