You can delete data from a segment by deleting one or more rows from the segment, by
deleting all rows from the segment, or by dropping fields from the segment.
To delete one or more rows in a segment:
-
Use the DELETE statement with a WHERE clause to specify a search condition.
The DELETE statement removes zero or more rows of a segment, depending on how many rows
satisfy the search condition that you specify in the WHERE clause.
The following DELETE statement deletes each row in the HOSPITAL segment that has
Hospital named ALEXANDRIA and SANTA
TERESA.
DELETE FROM PCB01.HOSPITAL WHERE HOSPNAME = 'ALEXANDRIA' OR HOSPNAME = 'SANTA TERESA';
When
this statement executes, IMS deletes any row from the HOSPITAL
segment that meets the search condition.
If IMS finds an error while executing your
DELETE statement, the application commits and rollbacks the changes and returns error codes in the
SQLIMSCODE and SQLIMSSTATE variables in the SQLIMSCA. (The data in the segment does not change.)
If the DELETE is successful, SQLIMSERRD(3) in the SQLIMSCA contains the number of deleted
rows. This number includes only the number of deleted rows in the segment that is specified in the
DELETE statement.
To delete every row in a segment:
-
Use the DELETE statement without specifying a WHERE clause.
The following DELETE statement deletes every row in the HOSPITAL
segment:
DELETE FROM HOSPITAL;
If the statement executes, the segment continues to exist (that is, you can insert
rows into it), but it is empty.