Subject Re: [ib-support] cursors in sp??
Author Helen Borrie
At 04:15 PM 03-10-02 -0700, you wrote:
>Hi,
>
>I'm pretty new to Firebird.

So far, Regina, you don't seem to have discovered the manuals. Get the IB6
beta docs from the IBPhoenix web site and put the Language Reference by
your side (LangRef.pdf). Even more useful, subscribe to the IBPhoenix CD
and get the Firebird manuals.

>Now, I have problems in creating store procedures. Is cursors allowed in SP?

Yes.

>Can I use Declare Cursor, Open cursor, Fetch, and Close cursor??

No.
PSQL (Firebird's programming SQL language) encapsulates database cursors in
the FOR SELECT...INTO...DO...[SUSPEND] construct.


>I'm trying to substract the quantity of a product after there were
>transactions.
>
>table product:
>prod_code | qty
>1 | 10
>2 | 20
>3 | 30
>4 | 40
>
>table transaction:
>prod_code | qty
>1 | 2
>3 | 4
>1 | 3
>
>so, the results of the quantity should be:
>
>prod_code | qty
>1 | 5
>2 | 20
>3 | 26
>4 | 40
>
>since there were no transaction for prod_code 2 and 4, so..the quantity
>remains the same.
>Problems:
>1. I need 0 quantity to prod_code 2 and 4. I need 0 not 'null' value.
>2. I guess I need cursors to do this. But so far I didn't success creating
>cursors in my procedures.
>
>Can anyone please help me?

Do get the docs so you can get your head around the programming
language. It is NOT the same as MSSQL, nor any other - since each RDBMS
implements triggers and SPs in its own way. I doubt that you will be able
to "wing" it based on your knowledge of MSSQL.

heLen