| Directives |
|
| Format |
Where:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description | Use
the SELECT directive to open, read and
query records from the specified data file or just to
read data from a specified file number. As each record is
read, ProvideX processes any logic you include following
the SELECT directive up to the NEXT
RECORD. When ProvideX encounters a NEXT
RECORD statement with no records found for a
nested SELECT, it will locate the
corresponding SELECT statement. If you include a WHERE clause, ProvideX will process only those records WHERE the condition is true. The BEGIN and END clauses are only supported for Keyed and Memory files. You can use these clauses with WindX-connected files. Note that, if you are using BEGIN and END in SELECT statements for files with descending keys, the END value must be lower than the BEGIN value. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| *Note* | Every SELECT must have a corresponding NEXT RECORD directive, and must be in the correct sequence. A mis-matched number of SELECT and NEXT RECORD directives can result in either an Error #27: Unexpected or incorrect WEND, RETURN, or NEXT, or an Error #28: No corresponding FOR for NEXT. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Because
ProvideX pads descending keys to their full length with
$FF$, the BEGIN value is item$+$FF$
and the END value should be item$+$00$
so that the ending key is less than the beginning key;
i.e., the correct format is currently SELECT *
FROM filename BEGIN item$
END item$+$00$. Although the incorrect statement SELECT * FROM filename BEGIN item$ END item$+$FF$may have worked in prior versions, it no longer does as of Version 4.20. You must either include a NEXT RECORD directive to end the SELECT loop or instruct ProvideX to exit the loop early (with an EXITTO directive).When an EXITTO directive is used, the file will be closed if SELECT specified a data filename rather than a channel. Also, in earlier versions of ProvideX, the CONTINUE and BREAK directives (and corresponding *CONTINUE and *BREAK labels) were not supported for use with SELECT / NEXT RECORD directives. As of Version 4.20, it is currently possible to BREAK and CONTINUE commands in SELECT structures. USING the TABLE option +PxPlus Exclusive The keyword TABLE before the name$ indicates that the value provided is the logical table name for the file as defined in the currently opened Data Dictionary file. See OPEN DICTIONARY for more details. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Formats 2 and 3 | SELECT
RECORD and SELECT KEY Options The SELECT .. NEXT RECORD statement can include syntax for full record contents or key portion of the record. SELECT RECORD allows the specification of a single variable, or * as per the READ RECORD directive. SELECT KEY reads the file and treats the key contents as if it were the data. A single variable can be specified to receive the key value or a formatted IOList; e.g.,
Refer to the examples below. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Read next Physical | If
you specify KNO=* on the SELECT directive, the system
will read and return the next physical record from the
file. The read will NOT utilize any of the key tables in
order to access the data. This significantly reduces the
overhead involved in the data retrieval process. Use of the Read Next Physical capability can greatly reduce the time it takes to process a file where the order of the data is not important.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| See Also | NEXT RECORD End SELECT Statment BREAK Immediate Exit of Loop, CONTINUE Initiates Next Iteration of Loop EXITTO End Loop, Transfer Control. Structured Error handling using ON ERR - an +PxPlus Exclusive |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Example | The
following illustrates use of the SELECT WHERE clause:
In the following example, SELECT KEY is issued to return the key portion of the record:
This uses the SELECT RECORD directive to return the full record contents:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||