DELETE [ HP Transact Documentation Update Notice ] MPE/iX 5.5 Documentation
HP Transact Documentation Update Notice
DELETE
Deletes KSAM files or data set entries. DELETE cannot be used with MPE
files.
Syntax
DELETE[(modifier)] file-name[,option-list];
DELETE specifies the deletion of one or more KSAM file entries or data
set entries. For multiple deletions, the entries to be deleted are
determined by match criteria specified in the match register. If you do
not specify match criteria for a multiple deletion, DELETE deletes all
entries in a chain or in the entire file or data set, depending on the
modifier.
If you are performing dynamic transactions (Transact/iX only), be aware
that transactions have a length limit. For a discussion about how DELETE
is affected by this limitation, see "Limitations" under "Dynamic
Roll-back" in Chapter 6.
NOTE After the first retrieval, Transact uses an asterisk (*) for the
call list to optimize subsequent retrievals of that data set.
Statement Parts
modifier To specify type of access to the KSAM file or data
set, choose one of the following modifiers:
none Deletes an entry from a
master set based on the key
value in the argument
register; this option does
not use the match register.
CHAIN Deletes entries from a detail
set or a KSAM chain. The
entries must meet any match
criteria set up in the match
register. The contents of
the key and argument
registers specify the chain
in which the deletion is to
occur. If no match criteria
are specified, all entries
are deleted. If match
criteria is used, all items
specified in the match
register must be included in
a LIST= option.
CURRENT Deletes the last entry that
was accessed from the KSAM
file or data set.
DIRECT Deletes the entry stored at
the specified record number
in a KSAM file, a detail set,
or a master set. Before
using this modifier, you must
store the record number as a
32-bit integer in the item
specified by the RECNO=
option.
PRIMARY Deletes the master set entry
stored at the primary address
of a synonym chain. The
primary address is located
through the key value in the
argument register.
____________________________
NOTE DELETE(PRIMARY) deletes
only one entry at the
primary location, and
the secondary entry, if
any, automatically
migrates to the primary
location after the
delete.
____________________________
RCHAIN Deletes entries from a detail
set or a KSAM chain in the
same manner as the CHAIN
option, only in reverse
order. For a KSAM file, this
operation is identical to
CHAIN.
RSERIAL Deletes entries from a data
set in the same manner as the
SERIAL option, except in
reverse order. For a KSAM
file, this operation is
identical to SERIAL.
SERIAL Deletes entries in serial
mode from a KSAM file or from
a data set that meet any
match criteria set up in the
match register. If no match
criteria are specified, all
entries are deleted. If
match criteria are specified,
the match items must be
included in a LIST= option.
file-name The KSAM file or data set to be accessed in the
deletion. If the data set is not in the home base
as defined in the SYSTEM statement, the base name
must be specified in parentheses as follows:
set-name(base-name)
option-list One or more of the following options, separated by
commas:
ERROR=label Suppresses the default error
[([item-name])] return that Transact normally
takes. Instead, the program
branches to the statement
identified by label, and the
stack pointer for the list
register is set to the data
item item-name. Transact
generates an error at execution
time if the item cannot be
found in the list register.
The item-name must be a parent.
If you omit item-name, as in
ERROR = label();, the list
register is cleared. If you
use an "*" instead of
item-name, as in ERROR =
label(*);, then the list
register is not touched.
LIST=(range-list) The list of items from the list
register to be used for the
DELETE operation. For data
sets, no child items can be
specified in the range list.
If the LIST= option is omitted
with any modifier, all the
items named in the list
register are used.
When the LIST= option is used,
only the items specified in a
LIST= option have their match
conditions applied when the
items are included in the match
register. When the LIST=
option is omitted, items which
appear in the list register and
the match register have their
match conditions applied.
Otherwise, the match conditions
for an item are ignored.
The match register can be used
only with the modifiers CHAIN,
RCHAIN, SERIAL, or RSERIAL.
Each retrieved entry is placed
in the area of the data
register indicated by LIST=
before any PERFORM= is
executed, and then the delete
is performed.
For all options of range-list,
the data items selected are the
result of scanning the data
items in the list register from
top to bottom, where top is the
most recent entry added to the
list register. (See Chapter 4
for more information on
registers.)
The LIST= option has a limit of
64 individually listed item
names and a limit of 255 items
specified by a range for a
TurboIMAGE data set.
All item names specified must
be parent items.
The options for range-list and
the data items they cause
DELETE to access include the
following:
(item-name) A single
data item.
(item-nameX: All the
item-nameY) data items
in the
range from
item-nameX
through
item-nameY.
In other
words, the
list
register is
scanned for
the
occurrence
of
item-nameY
closest to
the top of
the list
register.
From that
entry, the
list
register is
scanned for
item-nameX.
All data
items
between are
selected.
An error is
returned if
item-nameX
is between
item-nameY
and the top
of the list
register.
Duplicate
data items
can be
included or
excluded
from the
range,
depending
on their
position on
the list
register.
For
example, if
range-list
is A:D and
the list
register is
as shown,
then data
items A, B,
C, D, and D
are
selected.
For
database
files, an
error is
returned if
duplicate
entries are
selected.
If
item-nameX
and
item-nameY
are marker
items (see
the
DEFINE(ITEM)
verb) and
if there
are no data
items
between the
two on the
list
register,
no database
access is
performed.
(item-nameX:) All data
items in
the range
from the
last entry
through the
occurrence
of
item-nameX
closest to
the top of
the list
register.
(:item-nameY) All data
items in
the range
from the
occurrence
of
item-nameY
closest to
the top
through the
bottom of
the list
register.
(item-nameX, The data
item-nameY, ... items are
item-nameZ) selected
from the
list
register.
For
databases,
data items
can be
specified
in any
order. For
KSAM files,
data items
must be
specified
in the
order of
their
occurrence
in the
physical
record.
This order
need not
match the
order of
the data
items on
the list
register.
This option
is less
efficient
to use than
the options
listed
above.
(@) Specifies a
range of
all data
items of
file-name
as defined
in the data
dictionary.
The
range-list
is defined
as item-
name1:item-namen
for the
file.
(#) Specifies
an
enumeration
of all data
items of
file-name
as defined
in the data
dictionary.
The data
items are
specified
in the
order of
their
occurrence
in the
physical
record or
form as
defined in
the
dictionary.
This order
need not
match the
order of
the data
items in
the list
register.
( ) A null data
item list.
That is,
delete the
entry or
entries,
but do not
retrieve
any data.
LOCK Locks the specified file or
database. If a data set is
being accessed, the lock is set
the whole time that DELETE
executes. If LOCK is not
specified but the database is
opened in mode 1, which
requires a lock, the lock
specified by the type of
automatic locking in effect is
active while the entry is
processed by any PERFORM=
statements, but is unlocked
briefly before the next entry
is retrieved.
For a KSAM file, if LOCK is not
specified on DELETE but is
specified for the file in the
SYSTEM statement, then the file
is locked before each entry is
retrieved, remains locked while
the entry is processed by any
PERFORM= statements, but is
unlocked briefly before the
next entry is retrieved.
(DELETE is not allowed on MPE
files.)
Including the LOCK option
overrides SET(OPTION) NOLOCK
for the execution of the DELETE
verb.
A database opened in mode 1
must be locked while DELETE
executes. For transaction
locking, you can use the LOCK
option on the LOGTRAN verb
instead of the LOCK option on
DELETE if SET(OPTION) NOLOCK is
specified. If a lock is not
specified (for a database
opened in mode 1) an error is
returned.
See "Database and File Locking"
in Chapter 6 for more
information.
NOCOUNT Suppresses the message normally
generated to indicate the
number of deleted entries.
NOMATCH Ignores any match criteria set
up in the match register.
NOMSG Suppresses the standard error
message produced as a result of
a file or database error.
PERFORM=label Executes the code following the
specified label for every entry
retrieved by the DELETE verb
before the DELETE operation.
The entries can be optionally
selected by match criteria.
This option allows operations
to be performed on retrieved
entries without having to code
loop-control logic. You can
nest up to a maximum of ten
PERFORM options.
RECNO=item-name With the DIRECT modifier, you
[(subscript)] must define item-name to
contain the 32-bit integer
number (I(9,,4)) of the record
to be deleted.
With other modifiers, Transact
returns the record number of
the deleted record in the
32-bit integer item-name.
The item-name can be modified
with subscript if the
referenced item is an array
item. (See "Array
Subscripting" in Chapter 3.)
SINGLE Deletes only the first selected
entry.
SOPT Suppresses the optimization of
database calls. This option is
primarily intended to support a
database operation in a
performed routine that is
called recursively. The option
allows a different path for the
same detail set to be used at
each recursive entry, rather
than optimizing to the same
path. It also suppresses
generation of a call list of
"*" after the first call is
made. Use SOPT if you are
calling TurboIMAGE through the
PROC or CALL verbs. For an
example of how SOPT is used,
see "Examples" at the end of
the FIND verb description.
[REV BEG]For more detailed
information about SOPT, see
"Suppression of Optimization
versus WORKFILE" under the FIND
verb in this chapter.[REV END]
STATUS Suppresses the actions defined
in Chapter 7 under "Automatic
Error Handling." You may want
to add status checking to your
code if you use this option.
When STATUS is specified, the
effect of a DELETE statement is
described by the 32-bit integer
value in the status register:
Status Meaning
Register
Value
0 The DELETE operation was successful.
-1 A KSAM or MPE end-of-file condition
occurred.
>0 For a description of the condition
that occurred, refer to database or
MPE/KSAM file system error
documentation corresponding to the
value.
STATUS causes the following
with DELETE:
* Normal multiple
accesses/deletions
become single.
* The normal rewind done
by the DELETE is
suppressed, so CLOSE
should be used before
DELETE(SERIAL) or
DELETE(RSERIAL).
* The normal find of the
chain head by the DELETE
is suppressed, so PATH
should be used before
DELETE(CHAIN) or
DELETE(RCHAIN).
See "Using the STATUS Option"
in Chapter 7.
Examples
In the following example, the programmer wants to be sure that an entry
is not in MASTER-SET. Therefore, there are two acceptable conditions:
either a status register value of zero (delete successful) or a status
register value of 17 (database error 17--record not found) is acceptable.
DELETE MASTER-SET,
LIST=(KEY-ITEM),
STATUS;
IF STATUS = 17,0 THEN
DISPLAY "ENTRY REMOVED"
ELSE
DO
DISPLAY "ERROR ON DELETE FROM MASTER-SET";
GO TO ERROR-CLEANUP;
DOEND;
This example deletes all entries that contain a DEBT-LEVEL less than the
number entered by the user. DEBT-LEVEL is required in the LIST= option
because DELETE reads each record in the chain into the data register area
associated with DEBT-LEVEL in order to check the match criteria before
deleting the entry.
PROMPT(MATCH) DEBT-LEVEL,LT;
DELETE(CHAIN) DEBT-DETL,
LIST=(DEBT-LEVEL);
This example deletes only the last entry in the data set that matches the
zip code entered by the user.
PROMPT(MATCH) ZIP ("DELETE ZIP CODE");
DELETE(RSERIAL) DETAIL-SET,
SINGLE,
LIST=(NAME:ZIP),
PERFORM=LISTIT;
MPE/iX 5.5 Documentation