Clear

PURPOSE:  The CLEAR command deletes data records from the specified Data Set (DS) or indexes from the specified Data Index (DI) without deleting its Data Base Library (DBL) object. 

SYNTAX

CLEAR {DS; DI} name [IN DBL dbl_name]

name

references the DS (where records are to be removed) or DI (where indexes are to be removed).

IN DBL dbl_name

used to clear records from a DS or indexes from a DI in another DBL.

EXAMPLE

*CLEAR DS BOOKS_DBM2

*USE DS BOOKS_DBM2

*RECORDS

0 RECORDS

*CLEAR DI BOOKS_DBM2

NOTES:  Unlike the DELETE command, CLEAR DS does not read the records before removing them.  Because DELETE sequentially reads all the records, CLEAR DS is much more efficient than DELETE if all the records in a DS are to be deleted.

An alternative way to delete records from a DS without deleting the actual DS table is to use the ENTER command with the NEW option on the DS.  The NEW option deletes existing records.  At that point the ENTER mode may be exited, leaving an empty DS, or new records may be entered.

This command does not require the previous declaration of a DS.  If the DS has a DI, the CLEAR DS command marks the index as obsolete.  CLEAR DI command can be used to remove the index information from obsolete indexes.