[ label: ]
FOR [ EACH | FIRST | LAST ] record-phrase
[ , [ EACH | FIRST | LAST ] record-phrase ] ...
[ query-tuning-phrase ]
[ BREAK ]
[ BY expression [ DESCENDING ]
| COLLATE ( string , strength [ , collation ] ) [ DESCENDING ]
] ...
[ variable = expression1 TO expression2 [ BY k ] ]
[ WHILE expression ]
[ TRANSACTION ]
[ STOP-AFTER expression ]
[ on-error-phrase ]
[ on-endkey-phrase ]
[ on-quit-phrase ]
[ on-stop-phrase ]
[ frame-phrase ] :
for-body
|
Uses the criteria in the record-phrase to find the first record in the table that meets that criteria. The AVM finds the first record before any sorting.
Uses the criteria in the record-phrase to find the last record in the table that meets that criteria. The AVM finds the last record before sorting.
record
[ constant ] [ OF table ]
[ USE-INDEX index | TABLE-SCAN ]
[ USING [ FRAME frame ] field
[ AND [ FRAME frame ] field ] ...
]
[ WHERE expression ]
[ SHARE-LOCK | EXCLUSIVE-LOCK | NO-LOCK ]
[ NO-PREFETCH ]
|
QUERY-TUNING
(
{ [ LOOKAHEAD [ CACHE-SIZE integer ]
| NO-LOOKAHEAD
]
[ DEBUG { SQL | EXTENDED } | NO-DEBUG ]
[ SEPARATE-CONNECTION | NO-SEPARATE-CONNECTION ]
[ JOIN-BY-SQLDB | NO-JOIN-BY-SQLDB ]
[ BIND-WHERE | NO-BIND-WHERE ]
[ INDEX-HINT | NO-INDEX-HINT ]
}
)
|
For more information on the query-tuning-phrase, refer to the appropriate DataServer Guide (
OpenEdge Data Management: DataServer for ODBC,
OpenEdge Data Management: DataServer for Oracle, or
OpenEdge Data Management: DataServer for Microsoft SQL Server).
Here, the AVM accumulates the total CreditLimit for all the customers in the Customer table. Each time the value of the
State field changes, the AVM displays a subtotal of the
CreditLimit values for customers in that state.
BY expression [ DESCENDING
]
Sorts the selected records by the value of expression. If you do not use the BY option, the AVM retrieves records in the order of the index used to satisfy the
record-phrase criteria, or the primary index if no criteria is given. The DESCENDING option sorts the records in descending order (not in the default ascending order).
COLLATE ( string ,
strength [ ,
collation ] )
[ DESCENDING
]
|
RAW — Generates a collation value for the string based on its binary value.
|
|
CASE-SENSITIVE — Generates a case-sensitive collation value for the string based on a particular collation. If you specify this strength with an ICU collation, the AVM applies the ICU TERTIARY strength.
|
|
CASE-INSENSITIVE — Generates a case-insensitive collation value for the string based on a particular collation. If you specify this strength with an ICU collation, the AVM applies the ICU SECONDARY strength.
|
|
CAPS — Generates a collation value for the string based on its binary value after converting any lowercase letters in the string to uppercase letters, based on the settings of the Internal Code Page ( -cpinternal) and Case Table ( -cpcase) startup parameters.
|
|
PRIMARY — Generates a collation value for the base characters in the string.
|
|
SECONDARY — Generates a collation value for the base characters and any diacritical marks in the string.
|
|
TERTIARY — Generates a case-sensitive collation value for the base characters and any diacritical marks in the string.
|
|
QUATERNARY — Generates a case-sensitive collation value for the base characters and any diacritical marks in the string, and distinguishes words with and without punctuation. ICU uses this strength to distinguish between Hiragana and Katakana when applied with the ICU-JA (Japanese) collation. Otherwise, it is the same as TERTIARY.
|
|
strength does not evaluate to a valid value.
|
|
collation does not evaluate to a collation table residing in the convmap.cp file.
|
|
collation evaluates to a collation table that is not defined for the code page corresponding to the -cpinternal startup parameter.
|
variable =
expression1 TO
expression2 [ BY
k ]
When variable exceeds
expression2 (or is less than
expression2 if
k is negative) the loop ends. Since
expression1 is compared to
expression2 at the start of the first iteration of the block, the block can be executed 0 times. The AVM re-evaluates
expression2 on each iteration of the block.
Because the STOP-AFTER expression is re-evaluated for each iteration of a looping block, any changes made to the expression during the iteration effect the timer for the block. In the example, the
STOP-AFTER time limit is specified by the variable
stopTime, which is initially set to 30 seconds. The procedure contains an iterating block which runs a procedure that executes for 10 seconds.
On the first iteration of the DO WHILE TRUE loop,
stopTime is 30 seconds. The loop executes for 10 seconds, and then divides
stopTime by 2. On the second iteration, the
stopTime is 15 seconds; again the loop executes for 10 seconds, and then divides
stopTime by 2. On the third iteration, the
stopTime is 8 seconds. This time, the procedure
spinHere runs for 8 seconds and then raises
STOP. The
STOP condition is handled by the
DO block, and then the program displays the message
program finished.
In this example, procedure foo is run from within a timed block with a 10 second time limit; procedure bar is called from within the timed block, and contains an iterating block that specifies the
STOP-AFTER phrase. Because the value of the
STOP-AFTER expression evaluates to zero (that is, the current value of the
barLimit variable), the block within
bar is executed as an untimed block. However, the rules for execution of an untimed block within a timed block apply, so the untimed block in bar is executed with an implicit iteration time limit of 10 seconds.
ON ERROR UNDO
[ label1 ]
[ , LEAVE [ label2 ]
| , NEXT [ label2 ]
| , RETRY [ label1 ]
| , RETURN [ return-value |
ERROR [ return-value | error-object-expression ] |
NO-APPLY ]
| , THROW
]
|
ON ENDKEY UNDO
[ label1 ]
[ , LEAVE [ label2 ]
| , NEXT [ label2 ]
| , RETRY [ label1 ]
| , RETURN [ return-value |
ERROR [ return-value | error-object-expression ] |
NO-APPLY ]
|
ON QUIT
[ UNDO [ label1 ] ]
[ , LEAVE [ label2 ]
| , NEXT [ label2 ]
| , RETRY [ label1 ]
| , RETURN [ return-value |
ERROR [ return-value | error-object-expression ] |
NO-APPLY ]
]
|
ON STOP UNDO
[ label1 ]
[ , LEAVE [ label2 ]
| , NEXT [ label2 ]
| , RETRY [ label1 ]
| , RETURN [ return-value |
ERROR [ return-value | error-object-expression ] |
NO-APPLY ]
]
|
|
If you specify the -v6q startup parameter, an index component is involved in an equality match if it is used in the Record phrase conditions in the following form:
|
Where the expression is independent of any fields in the table that the index is being selected from. A condition involving OF and USING are equivalent to this form. A field is involved in a range match if it is used in a condition of this form:
field [ < | <= | > | >= | BEGINS ] expression
|
|
If you specify the -v6q startup parameter, the following list describes the rules the OpenEdge database manager uses to choose an index for an OpenEdge database:
|
|
If you specify the -v6q startup parameter, the AVM might have to scan all the records in the index to find those meeting the conditions, or it might have to examine only a subset of the records. This latter case is called bracketing the index and results in more efficient access. Having selected an index as previously described, the ABL compiler examines each component as follows to see if the index can be bracketed:
|
|
If you specify the v6q parameter, any conditions you specify in the record-phrase that are not involved in bracketing the selected index are applied to the fields in the record itself to determine if the record meets the overall record-phrase criteria. For example, assume that the f table has fields a, b, and c involved in two indexes:
|
Table 38 shows the index ABL selects and the bracketed part of the index for various
record-phrases.