Icon BOF

Returns whether or not a result set cursor is at the beginning of the result set.

Syntax
BOF(<CursorName>)

<CursorName> =

Previously-opened result set cursor

Returns
BOOLEAN

Usage
The BOF function returns whether or not a result set cursor is at the beginning of the result set. The BOF function only returns True once an attempt is made to navigate prior to the first row via the FETCH statement, or if the result set is empty and contains no rows.

When a result set cursor is first opened via the OPEN statement, the cursor is always positioned so that the BOF function will return True. If a result set is empty, then both the BOF and the EOF functions will return True.

Examples
-- This procedure uses an IF statement
-- to conditionally test if the State column
-- is equal to 'FL', and if so, to change it
-- to 'NY'

-- The whole update process is wrapped inside
-- of a transaction start..commit/rollback block

CREATE PROCEDURE UpdateState()
BEGIN
   DECLARE CustCursor CURSOR WITH RETURN FOR Stmt;
   DECLARE State CHAR(2) DEFAULT '';

   PREPARE Stmt FROM 'SELECT * FROM Customer';

   OPEN CustCursor;

   START TRANSACTION ON TABLES 'Customer';
   BEGIN

      FETCH LAST FROM CustCursor ('State') INTO State;

      WHILE NOT BOF(CustCursor) DO
         IF (State='FL') THEN
            UPDATE CustCursor SET 'State'='NY';
         END IF;
         FETCH PRIOR FROM CustCursor ('State') INTO State;
      END WHILE;

      COMMIT;

   EXCEPTION
      ROLLBACK;
   END;
END

SQL 2003 Standard Deviations
This function deviates from the SQL 2003 standard in the following ways:

DeviationDetails
ExtensionThis function is an ElevateDB extension.
Image