SELECT_GRID session environment option

Use the SELECT_GRID option of the SET ENVIRONMENT statement to define a default GRID clause for grid queries. This clause specifies a default grid or region from which to return a result set equivalent to logical UNION of qualifying rows from participating grid servers.

SELECT_GRID environment option

SET ENVIRONMENT SELECT_GRID { 'grid' | 'region' | DEFAULT }
Element Description Restrictions Syntax
grid Name of a default grid for queries with no GRID clause The grid must exist Identifier
region Name of a default region for queries with no GRID clause The region must exist Identifier

Usage

The SELECT_GRID session environment option can be set to any of three values:
'grid'
This specifies the default grid from which SELECT statements that include no GRID clause can return a result set that is the logical UNION of distinct qualifying rows from all of the participating grid servers in the specified grid. While the SELECT_GRID option of the SET ENVIRONMENT statement is set to the name of a grid, the database server that issued the SET ENVIRONMENT SELECT_GRID 'grid' statement interprets all queries as UNION grid queries.
'region'
This specifies the default region from which SELECT statements that include no GRID clause can return a result set that is the logical UNION of distinct qualifying values from all of the participating grid servers in the specified region. While the SELECT_GRID option of the SET ENVIRONMENT statement is set to the name of a region, the database server that issued the SET ENVIRONMENT SELECT_GRID 'region' statement interprets all queries as UNION grid queries.
DEFAULT
This setting specifies the default behavior that requires an explicit GRID clause. While the SELECT_GRID option of the SET ENVIRONMENT statement is set to DEFAULT, the database server does not process every query that has no GRID clause as a grid query. That is, the DEFAULT setting specifies that there is no default GRID clause for SELECT statements. Use this option to disable the effects of a previous SET ENVIRONMENT SELECT_GRID or SET ENVIRONMENT SELECT_GRID_ALL statement in the same session that defined a default GRID clause for all queries that include no GRID clause.

Unlike the SELECT_GRID_ALL option, the SELECT_GRID setting enables subsequent queries that include no GRID clause to behave as grid queries that return distinct values.

The SELECT_GRID and the SELECT_GRID_ALL options of the SET ENVIRONMENT statement are mutually exclusive. After you issue the SET ENVIRONMENT SELECT_GRID or SET ENVIRONMENT SELECT_GRID_ALL statement, issuing a different option of either statement in the same session replaces whatever the previous SET ENVIRONMENT SELECT_GRID or SET ENVIRONMENT SELECT_GRID_ALL statement established as the server behavior for grid queries in the session.

Restrictions on SELECT_GRID

Do not call the ifx_gridquery_skipped_nodes() function while the SELECT_GRID session environment variable is set to 'grid' or to 'region'.

The SELECT_GRID session environment option should not be set to 'grid' or to 'region' outside a grid context.

Examples of setting SELECT_GRID

The following statement establishes a default grid called inverness for the current session, and instructs the database server to interpret all queries that include no GRID clause as UNION grid queries for that grid:
SET ENVIRONMENT SELECT_GRID "inverness";
If cawdor were the name of a region in the inverness grid, the next example would instruct the database server to interpret all queries that include no GRID clause as UNION grid queries for the cawdor region, rather than having the entire inverness grid as their scope:
SET ENVIRONMENT SELECT_GRID "cawdor";
The following example overrides the effect of any previous SET ENVIRONMENT SELECT_GRID statement that established a default grid or a default region, and an implicit UNION operator, as the scope of subsequent queries that include no GRID clause:
SET ENVIRONMENT SELECT_GRID DEFAULT;
The statement above restores the default behavior for processing queries in the session, so that the database interprets only SELECT statements that explicitly include the GRID clause as grid queries.

For more information about grid queries, see the GRID clause and the HCL® Informix® Enterprise Replication Guide.