OPEN QUERY query { FOR | PRESELECT } EACH record-phrase
[ , { EACH | FIRST | LAST } record-phrase ] ...
[ query-tuning-phrase ]
[ BREAK ]
[ BY expression [ DESCENDING ]
| COLLATE ( string , strength [ , collation ] ) [ DESCENDING ]
] ...
[ INDEXED-REPOSITION ]
[ MAX-ROWS num-results ]
|
{ FOR
| PRESELECT
} EACH
record-phrase
record
[ [ LEFT ] ] [ OF table ]
[ WHERE expression ]
[ USING [ FRAME frame ] field
[ AND [ FRAME frame ] field ] ... ]
[ USE-INDEX index ]
[ SHARE-LOCK | EXCLUSIVE-LOCK | NO-LOCK ]
[ NO-PREFETCH ]
|
If you specify PRESELECT rather than FOR, then the AVM preselects the records for the query. During the preselect process, the AVM applies whatever locking is specified in the OPEN QUERY statement or, if none is specified, SHARE-LOCK. It then reads the ROWID for each record into the result list. (If you do not specify PRESELECT, the AVM might pass through the records anyway to presort them. In this case, the AVM applies NO-LOCK to each record during this pass.)
{ EACH
| FIRST
| LAST
} record-phrase
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 ]
)
|
BY expression [ DESCENDING
]
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.
|
If you specify this option, the AVM attempts to optimize subsequent REPOSITION TO ROWID operations on the query. This can improve the performance of REPOSITION operations that must jump over many records in a simple query. Optimization is not possible if the database is not an OpenEdge database, or sorting or preselection is performed. In these cases, the INDEXED-REPOSITION option is ignored and no error is reported.
The optimization has some side effects. When you perform a REPOSITION TO ROWID with this optimization, the AVM discards the original result list and begins a new one. Therefore, scrolling forward or backward in the list might return different records from before. Also, the values of the NUM-RESULTS and CURRENT-RESULT-ROW become invalid. If the query has an associated browse, any selections in that browse are also lost. Lastly, the vertical scrollbar thumb is disabled. Because of these side-effects, use this option selectively.
|
The locking options of the OPEN QUERY statement define the default locking for records fetched by the query. You can override the default by using a locking option in the GET statement. Note, however, that in the OPEN QUERY statement you can specify a separate lock type for each buffer; in the GET statement you can specify only one lock type that applies to all buffers in a join.
|
|
The record locking behavior specified for a query in the DEFINE BROWSE statement overrides the record locking behavior specified with the OPEN QUERY statement. The default record locking behavior of a browse widget is NO-LOCK. The default record locking behavior of a query defined with the OPEN QUERY statement is SHARE-LOCK. If you define a query and a browse widget for the query without explicitly defining record locking behavior, the query will have the NO-LOCK behavior.
|
|
Once the query has been opened, you cannot change the buffers that it references, even if the query is closed and re-opened. For example, a buffer, buff1, is created for the customer table in a DEFINE QUERY or OPEN QUERY for the query, qry1. The query is run and closed. You cannot now DEFINE or OPEN qry1 with buff1 for the item table. You can reuse buffers with CREATE QUERY, but you must re-run QUERY-PREPARE.
|
|
A ProDataSet data-relation defined with REPOSITION or SELECTION is overridden if a query is defined for a child relation data-source. Normally, if REPOSITION is not specified, the child query selects the children of the parent. But coding a query for the child data-source overrides whether or not a SELECTION or REPOSITION relation mode was defined.
|
CLOSE QUERY statement,
CREATE QUERY statement,
CURRENT-RESULT-ROW function,
DEFINE BROWSE statement,
DEFINE DATASET statement,
DEFINE QUERY statement,
GET statement,
NUM-RESULTS function,
QUERY-OFF-END function,
QUERY-PREPARE( ) method,
REPOSITION statement