Method SqlStatement():query() Foundation

Executes SQL statements returning a single result set

:query([nResultType], [<@xResult> | <cAlias>] ) -> <cAlias>
A #define constant from which determines how the result set is processed.
Possible ways to handle a result set
#define Description
USQL_RESULT_WORKAREA* The result set is returned as a workarea in the current workspace. Specify optional alias name.
USQL_RESULT_ARRAY The result set returned in an array, where each row is a sub-array.
USQL_RESULT_OBJECTS The result set returned in an array of objects. By default, all objects are DataObjects where the prototype name is the alias name.
USQL_RESULT_EVAL The result set not saved. Instead, each row of the result set is passed as an array to a code block.
USQL_RESULT_SINGLE_VALUE The result set is assumed to return only one column/one row. This single value is assigned to <@xResult>.
  1. Default
The values that can be used in the <nResultType> parameter depend on the DatabaseEngine being used. The following table lists the legal values for the respective DBEs.
Legal result types for DBEs
DatabaseEngine Result type
A variable passed by reference which receives the result value as specified via the <nResultType> parameter. If the USQL_RESULT_EVAL result type is used, a code block must be passed in <@xResult>. For all other result types, the variable can be of any type.
A character string or an expression returning a characters string which determines the alias name under which the result set is referenced in the current workspace. If the alias name already exists, the ordinal of the workarea is appended to the alias name.

This method returns the alias name of the workarea or the DataObject prototype.


The method :query() is used to retrieve a single result set from the SQL DBMS.


If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.