Previous Topic: @FIND/@OBTAIN Statements—accesses database recordsNext Topic: @FIND/@OBTAIN CURRENT


@FIND/@OBTAIN CALC/DUPLICATE

The @FIND/@OBTAIN CALC/DUPLICATE statement accesses a record based on the value of an element in the record defined as a CALC-key. The requested 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 records with the same CALC-key value as the record that is current of record type, provided that an @FIND/@OBTAIN CALC statement has previously accessed an occurrence of the same record type.

Currency

You do not need to establish currency before executing a @FIND/@OBTAIN CALC statement. However, record currency must be established by a prior @FIND/@OBTAIN CALC statement before executing a @FIND/@OBTAIN DUPLICATE statement.

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

Syntax

►►─┬─ @FIND ───┬──┬─┬─ CALC ─┬──┬─────────────────────────────────────────────►
   └─ @OBTAIN ─┘  │ └─ ANY ──┘  │
                  └─ DUPLICATE ─┘

 ►─── REC=record-name ────────────────────────────────────────────────────────►

 ►─┬───────────────────────────┬──────────────────────────────────────────────►◄
   └─ ,KEEP= ─┬─ SHARED ──────┬┘
              └─ EXCLUSIVE ───┘

Parameters

CALC/DUPLICATE,REC=record-name

Accesses the record specified by record-name using the value of its CALC-key.

CALC

Accesses 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. ANY is a synonym of CALC.

DUPLICATE

Accesses the next record with the same CALC-key value as the current 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, a status code of 0332 is returned.

REC=record-name

Names the record being accessed. Record-name can be a register containing the name of the record or a user-supplied value enclosed in quotation marks.

KEEP=

Optionally places a shared or exclusive lock on the accessed record.

SHARED

Places a shared lock on the specified record.

EXCLUSIVE

Places an exclusive lock on the specified record.

Example

To retrieve an occurrence of the EMPLOYEE record with the @FIND/@OBTAIN CALC/DUPLICATE statement, you must first initialize a field in program variable storage with the CALC-control element. The following statements initialize the CALC field EMPID and retrieve an occurrence of the EMPLOYEE record:

MVC   EMPID,INEMPID
@OBTAIN CALC,REC='EMPLOYEE'

Status codes

After completion of the @FIND/@OBTAIN CALC/DUPLICATE function, the ERRSTAT field in the IDMS communications block indicates the outcome of the operation. The following is a list of the acceptable status codes for this function and their corresponding meaning:

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 specified record is not in the subschema. The program has probably invoked the wrong subschema, or the record name has been misspelled.

0310

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

0318

The record has not been bound.

0326

The record or integrated indexing entry cannot be found, or no more duplicates exist for the named record.

0331

The retrieval statements 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.

When the KEEP parameter is specified a major code of 06 will be returned if an error occurs during the KEEP processing. The major code of 03 states that an error has occurred in the @FIND/@OBTAIN processing.