Using CICS commands to delete records

Records can never be deleted from an ESDS.

Deleting single records

You delete a single record in a KSDS or RRDS in one of three ways:

  1. Retrieve it for update with a READ UPDATE command, and then issue a DELETE command without specifying the RIDFLD option.
  2. Issue a DELETE command specifying the RIDFLD option.
  3. For a file opened in RLS mode, retrieve the record with a READNEXT or READPREV command with the UPDATE option, and then issue a DELETE command. This method is described in Updating and deleting records in a browse (VSAM RLS only).

If a full key is provided with the DELETE command, a single record with that key is deleted. So, if the data set is being accessed by way of an alternate index path that allows non-unique alternate keys, only the first record with that key is deleted. After the deletion, you know whether further records exist with the same alternate key, because you get the DUPKEY condition if they do.

Updating and deleting records in a browse (VSAM RLS only)

For files accessed in RLS mode, you can specify the UPDATE option on a READNEXT or READPREV command and then update or delete the record by issuing a DELETE or REWRITE command. If the browse command returns a TOKEN, the TOKEN remains valid only until the next browse request. The TOKEN is invalidated by REWRITE, DELETE, or UNLOCK commands, that specify the same value for TOKEN or by the commands READNEXT, READPREV, or ENDBR that specify the same REQID. If you issue many READNEXT commands with the UPDATE and TOKEN options, the TOKENS invalidate each other and only the last one will be usable. (For more explanation about the TOKEN option, see The TOKEN option.)

Use of the UPDATE option in a browse is subject to the following rules:

Locks for UPDATE

Specifying UPDATE on a READNEXT or READPREV command acquires an exclusive lock. The duration of these exclusive locks within a browse depends on the action your application program takes and on whether the file is recoverable or not.

Note:
An UNLOCK command does not free an RLS exclusive lock held by VSAM against a record acquired during a browse operation. An UNLOCK within a browse simply invalidates the TOKEN returned by the last request. Another READNEXT or READPREV in the browse also invalidates the TOKEN for the record read by the previous READNEXT or READPREV UPDATE command. Therefore, it's not necessary to use UNLOCK in an application program that decides not to update a particular record.

Deleting groups of records (generic delete)

You can use a generic key with the DELETE command. Then, instead of deleting a single record, all the records in the file whose keys match the generic key are deleted with the single command. However, this cannot be used if the KEYLENGTH value is equal to the length of the whole key (even if duplicate keys are allowed). The number of records deleted is returned to the application program if the NUMREC option is included with the command. If access is by way of an alternate index path, the records deleted are all those whose alternate keys match the generic key.

Read integrity

The NOSUSPEND option discussed in Read integrity (in RLS mode), also applies to the CICS browse commands when you are using them to update a file.

[[ Contents Previous Page | Next Page Index ]]