Subject Re: Can any one help me to fetch the next record using cursor
Author Svein Erling Tysvær
Hi Kapil!

I think Firebird 2.0 questions still does not belong to this list, but
your question is a general question applicable to most versions, so
here's an answer:

There are two kinds of stored procedures, executable and selectable.
You've written a selectable stored procedure (contains suspend), but
call it as if it was an executable stored procedure. To call it as a
selectable stored procedure, simply replace your call to the stored
procedure with

SELECT TABLENAME FROM GETALLTABLES()

Nor do I understand why your SP seems so complicated. Couldn't this be
implemented simply as

CREATE OR ALTER PROCEDURE GETALLTABLES RETURNS (TABLENAME VARCHAR(255))
AS
BEGIN
FOR SELECT RDB$RELATION_NAME FROM RDB$RELATIONS INTO :TABLENAME
DO
BEGIN
SUSPEND;
END
END !!

HTH,
Set

--- In firebird-support@yahoogroups.com, Kapil Patil wrote:
> Following is the stored procedure in FIREBIRD 2.0 BETA...
>
> As Per Standard Syntax of CURSOR the following procedure gives
> only first record from the recordset..
>
> Can any one help me to fetch the next record using cursor
>
> It will better if you provide small example using cursor
>
> Thanks in Advance..
>
>
==========================================================================
>
> SET TERM !! ;
>
> CREATE OR ALTER PROCEDURE GETALLTABLES RETURNS (TABLENAME
VARCHAR(255))
> AS
> DECLARE C CURSOR FOR (SELECT RDB$RELATION_NAME FROM
RDB$RELATIONS);
> BEGIN
> OPEN C;
> WHILE ( 1=1) DO
> BEGIN
> FETCH C INTO :TABLENAME;
> if(row_count=0) then leave;
> SUSPEND;
> END
> CLOSE C;
>
> END !!
>
> SET TERM ; !!
>
> Commit;
>
> Execute procedure getalltables;