Skip to main content

READNEXT KEY

Reads the next key and item id from an index.

Synopsis

READNEXT KEY keyname,itemID FROM slist [THEN statements] [ELSE statements]

Arguments

keyname A variable used to receive the key name from the select list.
itemID A variable used to receive the key item ID from the select list.
slist A select list to an existing index. A named select list specified as a variable name.

Description

The READNEXT KEY statement reads successive key identifiers from a select list, one key identifier per invocation. READNEXT KEY returns both the key name and the key item ID. The key identifier is read from the slist select list into the itemID variable.

READNEXT KEY is used on a select list created by either a SELECT or a SELECT ATKEY.

You can optionally specify a THEN clause, an ELSE clause, or both a THEN and an ELSE clause. READNEXT KEY executes the THEN clause if the select list pointer has not reached the end of the select list. The THEN clause is executed even when a key identifier is the null string. READNEXT KEY executes the ELSE clause if the select list pointer has reached the end of the select list, or the select list does not exist. The statements argument can be the NULL keyword, a single statement, or a block of statements terminated by the END keyword. A block of statements has specific line break requirements: each statement must be on its own line and cannot follow a THEN, ELSE, or END keyword on that line.

Examples

The following example used OPENINDEX to open an index to VOC on the attribute F1. The SELECT selects this index to a select list. The READNEXT KEY reads an item from the select list:

OPENINDEX 'VOC','F1' TO Idx.Fp ELSE ABORT
SELECT Idx.Fp TO Idx.List
READNEXT KEY Idx,Id FROM Idx.List

See Also

FeedbackOpens in a new tab