Subject | RE: [ib-support] How do i declare a cursor using Interbase workbe nch |
---|---|
Author | Martijn Tonies |
Post date | 2001-12-27T09:50:38Z |
Hi,
Stored Procedures or Triggers, you cannot use
DECLARE ... CURSOR. Perhaps you're used to Oracle?
If you want to iterate a resultset, use the FOR SELECT
... DO ...
If you take the example database EMPLOYEE, you'll see
an example of this in procedure ALL_LANGS.
Here's the code:
BEGIN
FOR SELECT job_code, job_grade, job_country FROM job
INTO :code, :grade, :country
DO
BEGIN
FOR SELECT languages FROM show_langs
(:code, :grade, :country) INTO :lang DO
SUSPEND;
/* Put nice separators between rows */
code = '=====';
grade = '=====';
country = '===============';
lang = '==============';
SUSPEND;
END
END
This procedure has two cursors and returns the values
to the output parameters in a SELECTable procedure.
Hope this helps,
Martijn Tonies
InterBase Workbench - the developer tool for InterBase and Firebird
http://www.interbaseworkbench.com
[Non-text portions of this message have been removed]
>I am trying to Declare cursor likeIn DSQL, the 'normal' SQL we are using today and in
>
>DECLARE myCursor CURSOR FOR
> Select OrderNo,OrderDate
> from tblOrders
>
>I am using interbase workbench and I am not able to compile this code.
>
>It gives an error message "an error occured at token DECLARE "
>So,can anybody help me in declaring and iterating through a cursor
Stored Procedures or Triggers, you cannot use
DECLARE ... CURSOR. Perhaps you're used to Oracle?
If you want to iterate a resultset, use the FOR SELECT
... DO ...
If you take the example database EMPLOYEE, you'll see
an example of this in procedure ALL_LANGS.
Here's the code:
BEGIN
FOR SELECT job_code, job_grade, job_country FROM job
INTO :code, :grade, :country
DO
BEGIN
FOR SELECT languages FROM show_langs
(:code, :grade, :country) INTO :lang DO
SUSPEND;
/* Put nice separators between rows */
code = '=====';
grade = '=====';
country = '===============';
lang = '==============';
SUSPEND;
END
END
This procedure has two cursors and returns the values
to the output parameters in a SELECTable procedure.
Hope this helps,
Martijn Tonies
InterBase Workbench - the developer tool for InterBase and Firebird
http://www.interbaseworkbench.com
[Non-text portions of this message have been removed]