Modifying Query Scope

The query engine resolves names and path expressions according to the name space that is currently in scope in the query. This is not the region scope attribute, but the scope of the query statement.

The initial name space for any query is composed of the region paths of the cache on the cache server and the attributes of those paths. New name spaces are brought into scope based on the FROM clause in the SELECT statement. For example, in this query the FROM expression evaluates to the collection of entry values in /portfolios. This is added to the initial scope of the query and status is resolved within the new scope.

FROM /portfolios
WHERE status = 'active'

Each FROM clause expression must resolve to a collection of objects available for iteration in the query expressions that follow. In the example above, /portfolios resolves to the Collection of entry values in the region. The entry value collection is iterated by the WHERE clause, comparing the status field to the string active. When a match is found, the value object is added to the return set.

In the following query, the collection specified in the first FROM clause expression is used by the second FROM clause expression and by the projections of the SELECT statement.

IMPORT cacheRunner.Position;
FROM /portfolios, positions.values posnVal TYPE Position
WHERE posnVal.qty > 1000.00

Note: You cannot change the order of the expressions in this FROM clause. The second expression depends on the scope created by the first expression.