SELECT Statement Query Results
The result of a SELECT
statement is a collection that implements the SelectResults
interface or it is UNDEFINED
.
The SelectResults
returned from the SELECT
statement is either a collection of objects or a Struct
collection containing the objects. (See also the API documentation for Query.)
Because a SELECT
statement returns a result, it can be composed with other expressions like the following example:
(SELECT DISTINCT * FROM /portfolios WHERE status = 'active').iterator
A collection of objects is returned in two cases:
When only one expression is specified by the projection list and that expression is not explicitly specified using the
fieldname:expression
syntaxWhen the
SELECT
list is * and a single collection is specified in the FROM clause
SELECT FROM |
* | Single Expressions | Multiple Expressions |
single expression | Objects | Objects. ( |
Struct |
multiple expressions | Struct |
Objects. ( |
Struct |
When a Struct
is returned, the name of each field in the Struct
is determined as follows:
- If a field is specified explicitly using the
fieldname:expression
syntax, the fieldname is used. - If the
SELECT
projection list is * and an explicit iterator expression is used in theFROM
clause, the iterator variable name is used as the field name. - If the field is associated with a region or attribute path expression, the last attribute name in the expression is used.
If names can not be decided based on these rules, arbitrary unique names are generated by the query processor.
These examples show how the projections and FROM clause expressions are applied.
SELECT <*> FROM <single expression> |
SELECT DISTINCT *
|
Returns the Collection of active portfolios objects. |
SELECT <single expression> FROM <multiple expression> (without fieldName mentioned) |
IMPORT javaobject.Position; SELECT DISTINCT secId
positions.values TYPE Position WHERE status =‘active’ |
Returns the Collection of secIds (CacheableString
objects) from the positions of active portfolios. |
SELECT <single expression> FROM
|
IMPORT javaobject.Position;SELECT DISTINCT secIdFieldName:secId
|
Returns struct<secIdField: CacheableString> for the active portfolios. (Compare to the results for the prior query.) |
SELECT <*> FROM <multiple expression> |
|
Returns a |
|
|
Returns a |