The IF statement allows the program to test for the presence of member record occurrences in a set and to determine the membership status of a record occurrence in a specified set; once the set has been evaluated, the IF statement specifies further action based on the outcome of the evaluation. For example, an IF statement might be used to determine whether a set occurrence is empty and, if it is empty, to erase the owner record.
Note: DML IF statements cannot be nested within PL/I IF statements. An alternative approach is to place DML IF statements within DO...END blocks, or their equivalents.
Native VSAM users: The IF statement is not valid for sets defined with member records that are stored in native VSAM datasets.
Depending on its format, the IF statement uses set or run-unit currency. The object set occurrence of an IF statement is determined by the owner of the current record of the named set; the object record occurrence is determined by the current of run unit.
Each IF statement contains a conditional phrase and an imperative statement. When an IF is issued, the DML precompiler first generates a call to the DBMS to execute the conditional phrase; the results of the test determine whether or not the imperative statement is executed.
►►── IF ─┬───────┬─ SET (set-name) ─┬─ EMPTY ─┬─ THEN imperative-statement;──►◄ ├─ NOT ─┤ └─ MEMBER ─┘ └─ ¬ ───┘
Evaluates the current owner occurrence of the named set for the presence of member record occurrences and, depending on the outcome of the evaluation, executes the imperative statement. Set-name must specify a set included in the subschema.
If NOT is specified, the imperative statement is executed only if the named set has one or more member records (that is, ERROR_STATUS is 1601). If NOT is omitted, the imperative statement is executed only if the set is empty (that is, ERROR_STATUS is 0000).
Determines whether the current record of run unit participates as a member in any occurrence of the named set and, depending on the outcome of the evaluation, executes the imperative statement. Set-name must specify a set included in the subschema.
If NOT is specified, the imperative statement is executed only if the named record is not a member of the named set (that is, ERROR_STATUS is 1601). If NOT is omitted, the imperative statement is executed only if the record is a member of the set (that is, ERROR_STATUS is 0000).
The following statement tests the COVERAGE_CLAIMS set for existing CLAIMS members and, if no occurrences of the CLAIMS record are found (ERROR_STATUS is 0000), moves a message to that effect to the location CLAIMS_WS:
If the current occurrence of the COVERAGE_CLAIMS set contains one or more occurrences of the CLAIMS record (ERROR_STATUS is 1601), the assignment statement is ignored and the next statement in the program is executed.
IF SET (COVERAGE_CLAIMS) EMPTY THEN CLAIMS_WS = 'NONE';
The following statement verifies that the EMPLOYEE record that is current of run unit is not a member of the current occurrence of the OFFICE_EMPLOYEE set before code is executed to connect the EMPLOYEE record to that set:
If the EMPLOYEE record is not a member of the OFFICE_EMPLOYEE set (ERROR_STATUS is 1601), the program performs the LINK_SET procedure. If the EMPLOYEE record is already a member of the OFFICE_EMPLOYEE set (ERROR_STATUS is 0000), the CALL statement is ignored and the next statement in the program is executed.
IF NOT SET (OFFICE_EMPLOYEE) MEMBER THEN CALL LINK_SET;
Upon completion of the IF function, the ERROR_STATUS field in the IDMS DB communications block indicates the outcome of the operation:
Either the set is empty or the record that is current of run unit is a member of the set.
Either the set is not empty or the record that is current of run unit is not a member of the set.
Currency has not been established for the named set.
Either an invalid set name has been specified or the current record of run unit is not a member of the named set.
A current record of run unit either has not been established or has been nullified by a preceding ERASE statement.
|
Copyright © 2014 CA.
All rights reserved.
|
|