Subject Re: [firebird-support] Cursor
Author Ann W. Harrison
> Dion wrote:
>
>>How do I join 2 tables in a stored procedure using firebird. Assigning
>>cursors to variables and doing a join works in MSQL. Can I do this in FB?

I replied:
> Cursors are part of stored procedures in V2. But why not just use the
> normal join syntax?
>

Dion wrote:
>
> No can do. Where can I get the syntax for cursor declaration and use. I am
> using V2.

Just as feedback to the developers, why can't you use a normal SQL join?
If there's a problem, perhaps it should be addressed more generally.


In a more helpful line, you should check the V2.0 release notes for
"Explicit Cursors" - here's a section of the article:

Syntax:
DECLARE [VARIABLE] <cursor_name> CURSOR FOR ( <select_statement> );
OPEN <cursor_name>;
FETCH <cursor_name> INTO <var_name> [, <var_name> ...];
CLOSE <cursor_name>;


Examples
1.
DECLARE RNAME CHAR(31);
DECLARE C CURSOR FOR ( SELECT RDB$RELATION_NAME
FROM RDB$RELATIONS );
BEGIN
OPEN C;
WHILE (1 = 1) DO
BEGIN
FETCH C INTO :RNAME;
IF (ROW_COUNT = 0) THEN
LEAVE;
SUSPEND;
END
CLOSE C;
END


Regards,


Ann