Previous Topic: FIND/OBTAINNext Topic: FIND/OBTAIN CURRENT


FIND/OBTAIN CALC/DUPLICATE

The FIND/OBTAIN CALC/DUPLICATE statement locates a record based on the value of an element defined as a CALC key in the record. The specified record must be stored in the database with a location mode of CALC. Before issuing the FIND/OBTAIN CALC/DUPLICATE statement, you must initialize a field in program variable storage with the CALC-key value.

You can use the DUPLICATE option to access duplicate records with the same CALC-key value as the record that is current of record type, provided that a FIND/OBTAIN CALC statement has previously accessed an occurrence of the same record type.

Currency

Following successful execution of a FIND/OBTAIN CALC/DUPLICATE statement, the accessed record becomes the current record of run unit, its record type, its area, and all sets in which it currently participates as member or owner.

Syntax
►►──┬─ FIND ───┬──┬────────────────────────┬───┬─┬─ CALC ─┬──┬────────────────►
    └─ OBTAIN ─┘  └─ KEEP ─┬─────────────┬─┘   │ └─ ANY ──┘  │
                           └─ EXCLUSIVE ─┘     └─ DUPLICATE ─┘

 ►──── RECORD (record-name); ─────────────────────────────────────────────────►◄
Parameters
FIND/OBTAIN CALC/DUPLICATE RECORD (record-name)

Locates the record specified by record-name based on its CALC-key value:

CALC/ANY

Locates the first or only occurrence of the designated record type whose CALC key matches the value of the CALC data item in program variable storage. CALC and ANY are synonyms.

DUPLICATE

Locates the next record with the same CALC key value as the current of record type. Use of the DUPLICATE option requires prior selection of an occurrence of the same record type with the CALC option. If the value of the CALC key in variable storage is not equal to the CALC-key field of the current of record type, an error status of 0332 is returned.

KEEP EXCLUSIVE

Places a shared (KEEP) or exclusive (KEEP EXCLUSIVE) lock on the accessed record.

Example

To retrieve an occurrence of the EMPLOYEE record by using the FIND/OBTAIN CALC/DUPLICATE statement, you must first initialize the variable-storage field that contains the CALC-control element. The following statements initialize the CALC field EMP_ID_0415 and retrieve an occurrence of the EMPLOYEE record:

EMP_ID_0415 = EMP_ID_IN;
OBTAIN CALC RECORD (EMPLOYEE);
Status Codes

Upon completion of the FIND/OBTAIN CALC/DUPLICATE function, the ERROR_STATUS field in the IDMS DB communications block indicates the outcome of the operation:

0000

The request has been serviced successfully.

0301

The area in which the named record participates has not been readied.

0306

A successful FIND/OBTAIN CALC has not yet been executed (applies to the DUPLICATE option only).

0308

The named record is not in the subschema. The program probably invoked the wrong subschema.

0310

The subschema specifies an access restriction that prohibits retrieval of the named record.

0318

The record has not been bound.

0326

The record cannot be found or no more duplicates exist for the named record.

0331

The retrieval statement format conflicts with the record's location mode.

0332

The value of the CALC data item in program variable storage does not equal the value of the CALC data item in the current record (applies to the DUPLICATE option only).

0364

The CALC-control element has not been described correctly either in the program or in the subschema.

0370

A database file will not open properly.

If the KEEP parameter is specified in a FIND/OBTAIN statement, and an error occurs during KEEP processing, the major code 06 is returned.

Note: For more information, see KEEP CURRENT later in this chapter. The major code 03 is returned if an error occurs during FIND/OBTAIN processing.