Previous Topic: FIND / GET WITHIN DBKEYLISTNext Topic: FIND / GET WITHIN SET


FIND / GET WITHIN Index SET

FIND/GET WITHIN index SET retrieves records using the name of an index set and the index-sort-key fields specified in the WHERE clause.

Access mode: The syntax below is invalid when the access switch is set to IDMS.

FIND locates database records but does not retrieve them into the report file. GET locates database records and does retrieve them into the report file.

Syntax:

►►─┬─ FINd ─┬─┬─────────────────────────────┬─────────────────────────────────►
   └─ GET ──┘ ├─ FIRst ─┬────────────────┬──┤
              │         └─ record-count ─┘  │
              ├─ LASt ─┬────────────────┬───┤
              │        └─ record-count ─┘   │
              ├─ NEXt ◄ ─┬────────────────┬─┤
              │          └─ record-count ─┘ │
              ├─ PRIor ─┬────────────────┬──┤
              │         └─ record-count ─┘  │
              └─ ALL ───────────────────────┘

 ►─┬─────────────────────────────────────────────────┬─ records ──────────────►
   └─┬────────────┬─ record-name ─┬────────────────┬─┘
     └─ view-id. ─┘               └─ (field-list) ─┘

 ►─┬─────────────────────────────┬────────────────────────────────────────────►
   └─ withIN index-set-name set ─┘

 ►─┬───────────────────────────────────────────┬──────────────────────────────►◄
   └─ WHEre index-criteria ─┬────────────────┬─┘
                            └─ AND criteria ─┘
►►─── REPeat with ─┬────────────────────────────┬─────────────────────────────►
                   ├─ FIRst ─┬────────────────┬─┤
                   │         └─ record-count ─┘ │
                   ├─ LASt ─┬────────────────┬──┤
                   │        └─ record-count ─┘  │
                   ├─ NEXt ─┬────────────────┬──┤
                   │        └─ record-count ─┘  │
                   ├─ PRIor ─┬────────────────┬─┤
                   │         └─ record-count ─┘ │
                   └─ ALL ──────────────────────┘

 ►─┬─────────────────────────────────────────────────┬─ records ──────────────►
   └─┬────────────┬─ record-name ─┬────────────────┬─┘
     └─ view-id. ─┘               └─ (field-list) ─┘

 ►─┬───────────────────────────────────────────┬──────────────────────────────►◄
   └─ WHEre index-criteria ─┬────────────────┬─┘
                            └─ AND criteria ─┘

Parameters:

FIRST record-count

Retrieves the first n (where n defaults to 1) records at the beginning of the current occurrence of the set type.

LAST record-count

Retrieves the last n (where n defaults to 1) records at the end of the current occurrence of the set type.

NEXT record-count

Retrieves the next n (where n defaults to 1) records, starting with the record that follows the current record in the current occurrence of the set.

PRIOR record-count

Retrieves the prior n (where n defaults to 1) records starting with the record that precedes the current record in the current occurrence of the set.

ALL

Retrieves all member records in the current occurrence of the set type.

view-id

The qualifying ID for the record or logical record name. Use view-id when you are signed on to multiple subschemas. View-id refers to the subschema where the record (or logical record) can be found.

record-name

The name of the indexed record to be retrieved. If the WITHIN SET clause does not specify the index-set name, use record-name. Record-name must be a record in an index set. If you have a WHERE clause, specify record-name. If a database record name is the same as a CA OLQ keyword, the name should be enclosed in quotation marks.

WITHIN index-set-name

Specifies the name of the index set used for retrieval. If record-name is not specified or if record-name participates in more than one index set, this parameter is required.

WHERE

Specifies comparison expressions based on the index field or its subfields. The criteria is evaluated for each entry in the index; a record is retrieved only when an index satisfies the conditions specified in this parameter.

AND criteria

Specifies criteria to be used by CA OLQ when selecting a record occurrence.

REPEAT

Duplicates an immediately preceding FIND/GET WITHIN index SET (or REPEAT for FIND/GET WITHIN index SET) command.

FIRST record-count

Retrieves the first n (where n defaults to 1) records at the beginning of the current set.

LAST record-count

Retrieves the last n (where n defaults to 1) records at the end of the current set.

NEXT record-count

Retrieves the next n (where n defaults to 1) records starting with the record that follows the current record in the current set.

PRIOR record-count

Retrieves the prior n (where n defaults to 1) records starting with the record that precedes the current record in the current set.

ALL

Retrieves all member records in the current set.

view-id

The qualifying ID for the record or logical record name. Use view-id when you are signed on to multiple subschemas. View-id refers to the subschema where the record (or logical record) can be found.

record-name

The indexed record to be retrieved. Use this parameter if the WITHIN SET clause does not specify the index-set name. Record-name must be a record in an index set. If you specify a WHERE clause, also specify record-name. Enclose the database record name in quotation marks if it is the same as a CA OLQ keyword.

WHERE

Specifies comparison expressions based on the index field or its subfields. The criteria is evaluated for each entry in the index; a record is retrieved only when an index satisfies the conditions specified in this parameter.

The rules for index-criteria are the same as for the WHERE clause criteria parameter.

AND criteria

Specifies criteria used in selecting a record occurrence.

If the selection criteria are changed and index-set retrieval is preferred, specify the record name in the REPEAT command.

Examples:

The following examples illustrate the use of the GET WITHIN index SET command and associated REPEAT commands based on the set occurrence diagram shown below:

Illustrates the use of the GET WITHIN index SET command and associated REPEAT commands based on the set occurrence diagram

Get First

A GET command retrieves the first SKILL record in the SKILL-NAME-NDX index set:

get first skill (skill-id-0455 skill-name-0455 skill-dbkey)
 record in skill-name-ndx set

 SKILL
    SKILL-DBKEY      :    0/5007106:1
    SKILL-ID-0455    :    1030
    SKILL-NAME-0455  :    'ACCT MGT    '
 END OF RECORD

Repeat

A REPEAT command retrieves the next SKILL record in the SKILL-NAME-NDX index set:

repeat with next

 SKILL
    SKILL-DBKEY      :    0/5007107:1
    SKILL-ID-0455    :    1040
    SKILL-NAME-0455  :    'DEV MGT    '
 END OF RECORD

For more information:

Global Syntax