Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 6: CICS File Handling


DELETE

The DELETE command removes a record from a key-sequenced or relative record file. You can delete the record you just read for update, or you can name the record to delete directly in the RIDFLD option.

Syntax of the DELETE command

  • FILE - the name of the file that contains the record to be deleted. This name must be defined in the File Control Table (FCT).
  • RIDFLD - for a key-sequenced file, the field that contains the key of the record to delete. If RRN or RBA is specified, the field is interpreted as a relative record number or a relative byte address.
  • RRN - the RIDFLD value is a relative record number for a relative record file.
  • RBA - the RIDFLD value is a relative byte address for a key-sequenced file.
  • If the record was already read for update, you can omit the RIDFLD option and the current (held) record is deleted.

The two ways to delete

  • Delete after a read for update: issue READ with the UPDATE option, then DELETE with no RIDFLD. This is the safest form because you know the record exists and you hold it.
  • Delete by key: issue DELETE with the RIDFLD option naming the record. If the record does not exist, the NOTFND condition occurs.
  • DELETE works on key-sequenced and relative record files. Entry-sequenced (ESDS) records cannot be deleted with EXEC CICS.
  • Example:-
    * Delete a record previously read for update EXEC CICS DELETE FILE('CUSTMAS') RESP(RESPONSE-CODE) END-EXEC. * Delete a record that was not previously read for update EXEC CICS DELETE FILE('CUSTMAS') RIDFLD(CM-CUSTOMER-NUMBER) RESP(RESPONSE-CODE) END-EXEC. IF RESPONSE-CODE = DFHRESP(NOTFND) MOVE 'Customer not found.' TO MESSAGEO ELSE IF RESPONSE-CODE NOT = DFHRESP(NORMAL) PERFORM 9999-TERMINATE-PROGRAM END-IF.

Releasing a record with UNLOCK

  • The UNLOCK command releases a record previously held by a READ with the UPDATE option, without changing or deleting it.
  • Its only option is FILE, naming the file that contains the held record.
  • A held record is released automatically when the task ends, so UNLOCK is mainly for long tasks that want to free the lock early.
  • UNLOCK has no effect on files defined as recoverable in a way that changes recovery; it simply releases the exclusive control.





© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant