Set Indirect (SI)

Command title

Set Indirect


This command sets the criterion to be used when opening a table indirectly.

COBOL syntax

MOVE 'SI'                   TO xxxx-COMMAND.

C syntax

memcpy( tbCommArea.tbCommand, "SI", 2 );
TBLBASE( &tbParm, &tbCommArea, pInDirectOpenCriterion );




Set Indirect (SI) is used in conjunction with the Open Indirect option of the OR and OW commands. A common use of this feature is to choose a particular table from a set of different tables depending upon a date criterion supplied by the application.

To utilize Indirect Open, a table of table names (the primary table) must exist and be defined with only two fields: table-name (8 bytes) and lookup-value (up to 50 bytes) starting in location 9. The primary table must have a Sequential organization and the second field, lookup-value, must be defined as the key.

The SI command supplies an indirect open search criterion, which is saved for use with any subsequent indirect open command. The next occurring indirect open uses the table named in the open command as a primary table. The row in the primary table with the highest key less than or equal to the saved criterion is selected; its table-name field becomes the secondary table, which is the actual table opened by the indirect open command. The name of the secondary table is returned in the TABLE field of the xxxx-COMMAND-AREA.

To specify an indirect open, set the value I in the INDIRECT-OPEN field of the xxxx-COMMAND-AREA, before performing the open. An indirect open resets this field to blank.

The criterion is saved until reset by another SI command. It may be used with more than one indirect open.

Return value

In addition to possible open errors (see Open for Write (OW), Open for Read (OR)), ERROR 0005 may occur if the search criterion are not matched.





See also

Access a table indirectly