![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » ElevateDB Technical Support » Product Manuals » ElevateDB Version 2 SQL Manual » SQL/PSM Statements » FETCH |
FETCH [<Orientation>] [FROM] <CursorName> [[(<ColumnName> [,<ColumnName>])] INTO <TargetName> [,<TargetName>]] <Orientation> = NEXT|PRIOR|FIRST|LAST|{ABSOLUTE|RELATIVE} <IntegerValue> <TargetName> = <VariableName>|<ParameterName>|NEWROW.<ColumnName>
Orientation | Description |
NEXT | Navigates to the next row in the cursor. If there are no more subsequent rows in the cursor, then the EOF flag is set for the cursor and the current row stays the same. If there are no rows in the cursor, then both the BOF and EOF flags are set for the cursor. |
PRIOR | Navigates to the prior row in the cursor. If there are no more prior rows in the cursor, then the BOF flag is set for the cursor and the current row stays the same. If there are no rows in the cursor, then both the BOF and EOF flags are set for the cursor. |
FIRST | Navigates to the first row in the cursor. If there are no rows in the cursor, then both the BOF and EOF flags are set for the cursor. |
LAST | Navigates to the last row in the cursor. If there are no rows in the cursor, then both the BOF and EOF flags are set for the cursor. |
ABSOLUTE | Navigates to the Nth row specified. If the Nth row is greater than the number of rows in the cursor, then the EOF flag is set for the cursor. If there are no rows in the cursor, then both the BOF and EOF flags are set for the cursor. |
RELATIVE | Navigates to the Nth row specified relative to the current row position. If the specified relative row is negative and the current row position minus the Nth row is less than 0, then the BOF flag is set for the cursor. If the current row position plus the Nth row is greater than the number of rows in the cursor, then the EOF flag is set for the cursor. If there are no rows in the cursor, then both the BOF and EOF flags are set for the cursor. |
-- The following job backs up all tables in all databases -- defined in the current system at 11:00 PM every evening. CREATE JOB Backup RUN AS "System" FROM DATE '2006-01-01' TO DATE '2010-12-31' DAILY BETWEEN TIME '11:00 PM' AND TIME '11:30 PM' CATEGORY 'Backup' BEGIN DECLARE DBCursor CURSOR FOR DBStmt; DECLARE DBName VARCHAR DEFAULT ''; PREPARE DBStmt FROM 'SELECT * FROM Databases'; OPEN DBCursor; FETCH FIRST FROM DBCursor ('Name') INTO DBName; WHILE NOT EOF(DBCursor) DO IF (DBName <> 'Configuration') THEN EXECUTE IMMEDIATE 'BACKUP DATABASE "' + DBName + '" AS "' + CAST(CURRENT_DATE AS VARCHAR(10)) + '-' + DBName + '" TO STORE "Backups" INCLUDE CATALOG'; END IF; FETCH NEXT FROM DBCursor ('Name') INTO DBName; END WHILE; CLOSE DBCursor; END
Deviation | Details |
Columns list | The list of columns to fetch from is an ElevateDB extension. |
Exceptions | The SQL standard dictates that exceptions are raised whenever a fetch operation cannot be completed due to a BOF or EOF condition or a row not being found. ElevateDB does not raise an exception in any of these cases and instead uses the BOF and EOF functions to indicate these conditions. |
This web page was last updated on Friday, January 31, 2025 at 08:42 AM | Privacy Policy![]() © 2025 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |