Records can never be deleted
from an ESDS.
You delete a single record in a KSDS or RRDS in one of three ways:
- Retrieve it for update with a READ UPDATE
command, and then issue a DELETE command
without specifying the RIDFLD option.
- Issue a DELETE command specifying the
RIDFLD option.
- 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:
- You can specify UPDATE within a browse only if the file is accessed
in RLS mode. If you specify UPDATE for a file accessed in non-RLS
mode, CICS® returns an INVREQ condition.
- You can specify UPDATE only on the READNEXT and READPREV commands, not on the STARTBR or RESETBR
commands.
- CICS supports only one TOKEN in a browse sequence, and the TOKEN
value on each READNEXT or READPREV command
overwrites the previous value.
- You can mix update and non-update requests within the same browse.
- You must specify on the READNEXT, DELETE, or UNLOCK command
the TOKEN to be returned by the corresponding READNEXT or READPREV command.
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.
- If the file is recoverable and you decide to DELETE or REWRITE the last record acquired by a read
for update in a browse (using the associated token), the VSAM exclusive
lock remains active until completion of the UOW. That is, until
successful syncpoint or rollback.
- If the file is not recoverable and you decide to DELETE or REWRITE the
last record acquired, the lock is released either when you next issue
an ENDBR command or when you issue a subsequent READNEXT or READPREV command. This is explained more fully
in RLS Record level locking.
- If you decide not to update the last record
read, CICS frees the exclusive lock either when your program issues
another READNEXT or READPREV command
in the browse, or ends the browse.
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.
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.
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 ]]