Subject CURSOR logic
Author Raymond Kennington
Does the following SUSPEND the last record of the table or should the
code be written as below the first example?

The second sequence appears to test for an empty remaining set prior to
fetching. The first sequence appears to FETCH before testing if there
are any rows available to retrieve.

Thanks.
Raymond.


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

DECLARE RNAME CHAR(31);
DECLARE C CURSOR FOR ( SELECT RDB$RELATION_NAME
FROM RDB$RELATIONS );
BEGIN
OPEN C;
WHILE (1 = 1) DO
BEGIN
IF (ROW_COUNT = 0) THEN
LEAVE;

FETCH C INTO :RNAME;
SUSPEND;
END

CLOSE C;
END