Return type:
Applies to:
QUERY-PREPARE ( predicate-expression )A CHARACTER expression that evaluates to an OPEN QUERY FOR EACH statement without the OPEN QUERY . You can also use a field phrase.If the QUERY-PREPARE method encounters an error, it returns FALSE and generates an error message, but does not raise ERROR. If you use the QUERY-PREPARE method in a statement that uses the NO-ERROR option and an error occurs, the QUERY-PREPARE method returns FALSE and diverts the error to the ERROR-STATUS system handle. In either instance, ERROR-STATUS:ERROR returns FALSE. You can get information on the error through the GET-MESSAGE method of the ERROR-STATUS system handle, as usual.
Note: The QUERY-PREPARE method is compatible with indexed reposition of queries with joins. In predicate-expression, just include the INDEXED-REPOSITION option. For more information on the INDEXED-REPOSITION option, see the reference entry for the OPEN QUERY statement.
hQuery:QUERY-PREPARE("FOR EACH Customer WHERE Customer.CustNum < 9)".
hQuery:QUERY-PREPARE(my-predicate).
hQuery:QUERY-PREPARE("FOR EACH Customer WHERE Customer.CustNum > " +STRING(my-integer)).Unless explicitly specified otherwise in the predicate-expression, the default record lock type for the QUERY-PREPARE method is NO-LOCK.Like the FOR statement, the QUERY-PREPARE method predicate-expression supports the BREAK and BY options for sorting and accumulating data by break groups.
hQuery:QUERY-PREPARE("FOR EACH Customer WHERE Customer.CustNum > 50BREAK BY Customer.SalesRep BY Customer.Country").To test whether a break group has changed, you can use the FIRST-OF( ) method and LAST-OF( ) method of the query object handle.
hQuery:QUERY-PREPARE("FOR EACH Customer WHERE Customer.Name = " +QUOTER(my-name)).
Note: The NAME attribute of the Temp-table object handle is writeable for dynamic and AVM-generated temp-tables. You might need to update a predicate-expression that references a renamed temp-table with new strings using the new table name.
See also:
© 2013 Progress Software Corporation and/or its subsidiaries or affiliates. |