Previous Topic: MODIFYNext Topic: Testing Set Membership


ERASE and DISCONNECT

The ERASE function deletes a record occurrence from the database. The DISCONNECT function removes a member record occurrence from a set without deleting it from the database. You can only issue a DISCONNECT if the set's membership option is Optional rather than Mandatory.

At Commonweather, the EMPLOYEE record is Optional in the DEPT-EMPLOYEE and OFFICE-EMPLOYEE sets to allow for transfers. For example, if Sandy Shore transfers from the MIS to the Sales department we disconnect her record occurrence from the MIS occurrence of the DEPT-EMPLOYEE set and connect it to the Sales occurrence. If the set membership option was Mandatory instead of Optional, we would have to erase Sandy Shore's EMPLOYEE record and re-store it in order to effect the transfer.

Prior to a DISCONNECT, you must set the current of record type to the record about to be disconnected. After the DISCONNECT, the current of set for the set from which the record was disconnected becomes null, but other currencies associated with the set (such as next and prior) remain unchanged.

The ERASE function disconnects the target record from all sets in which it participates as a member prior to deleting the record from the database. The record must be current of run unit at the time of the ERASE.

By erasing John Done's COBOL expertise in the following figure, we implicitly disconnect it from the two sets in which it is a member: EMP-EXPERTISE and SKILL-EXPERTISE. Because membership is Mandatory in the EMP-EXPERTISE set, we cannot simply disconnect the record without erasing it.

Once a record is erased, all currencies for the record and the sets in which it participates become null. (Issuing FIND NEXT WITHIN SET, FIND PRIOR WITHIN SET, FIND NEXT WITHIN AREA, and FIND PRIOR WITHIN AREA functions still locate the correct records.)

A record can be deleted using the ERASE function only if all sets it owns are empty. In our example, we were able to erase John Done's COBOL expertise because it did not own any sets. If we attempt to erase the COBOL SKILL record that owns several EXPERTISE records, an error condition results.

Owners of sets containing members can be deleted using the ERASE function by specifying one of the following options:

If a deleted member record is also an owner in another set, its members are treated in a like manner. All members must be accounted for before deleting an owner.