Clear Library (CLRLIB)

The Clear Library (CLRLIB) command deletes all of the objects that you have the authority to delete from the specified library. This command does not delete the specified library, only the objects in it for which you have object existence (*OBJEXIST) authority. The other objects remain in the library. If any object in the library is in use (locked by another thread or job), the object cannot be deleted.

Restrictions:

  1. You must have object existence (*OBJEXIST) authority for every object being deleted and use (*USE) authority for the library.
  2. This command cannot be used to clear IBM system libraries. Message CPD2103 is sent if an IBM system library is specified and the CLRLIB command is not run.
  3. This command is conditionally threadsafe. The following restriction applies:
    • In multithreaded jobs, this command is not threadsafe for distributed files and fails for distributed files that use relational databases of type *SNA.

Parameters

Keyword Description Choices Notes
LIB Library Name, *CURLIB Required, Positional 1
ASPDEV ASP device Name, *, *CURASPGRP, *SYSBAS Optional

Library (LIB)

Specifies the library to be cleared of all objects for which you have object existence (*OBJEXIST) authority. If you do not have *OBJEXIST authority for an object, that object remains in the library. If QGPL is specified or defaulted via *CURLIB, an inquiry message (CPA2129) is sent to verify that you want to clear the QGPL library.

This is a required parameter.

*CURLIB
The current library for the thread is to be cleared. If no current library exists in the library list for the current thread, the QGPL library is cleared.
name
Specify the name of the library to be cleared.

ASP device (ASPDEV)

Specifies the auxiliary storage pool (ASP) device where storage is allocated for the library to be cleared. If the library to be cleared is not part of the thread's library name space, this parameter must be specified to ensure the correct library is the target of the clear library operation.

Note: If this parameter is specified when *CURLIB is specified for the Library (LIB) parameter, ASPDEV(*) is the only valid value.

*
The ASPs that are currently part of the thread's library name space will be searched to find the library. This includes the system ASP (ASP 1), all defined basic user ASPs (ASPs 2-32), and, if the thread has an ASP group, all primary and secondary ASPs in the ASP group.
*CURASPGRP
If the thread has an ASP group, the primary and secondary ASPs in the ASP group will be searched to find the library. The system ASP (ASP 1) and defined basic user ASPs (ASPs 2-32) will not be searched.
*SYSBAS
The system ASP (ASP 1) and all defined basic user ASPs (ASPs 2-32) will be searched to find the library. No primary or secondary ASPs will be searched, even if the thread has an ASP group.
name
Specify the name of the primary or secondary ASP device to be searched to find the library. The primary or secondary ASP must have been activated (by varying on the ASP device) and have a status of 'Available'. The system ASP (ASP 1) and defined basic user ASPs (ASPs 2-32) will not be searched.

Note: To specify a specific auxiliary storage pool (ASP) device name, you must have use (*USE) authority for each ASP device in the ASP group.

Examples

Example 1: Clearing a Library

CLRLIB   LIB(A)

This command deletes all objects in library A that are not in use and for which you have object existence (*OBJEXIST) authority.

Example 2: Deleting a Library in an Independent Auxiliary Storage Pool (ASP)

CLRLIB   LIB(INVENTORY) ASPDEV(SALES)

This command deletes all objects in library INVENTORY in the independent auxiliary storage pool (ASP) named SALES that are not in use and for which you have object existence (*OBJEXIST) authority. The SALES ASP must have been activated (by varying on the ASP device) and have a status of 'Available'.

Error messages

*ESCAPE Messages

CPFB8ED
Device description &1 not correct for operation.
CPF210D
Library &1 in use.
CPF2110
Library &1 not found.
CPF2113
Cannot allocate library &1.
CPF2129
Clear or delete of system library &1 canceled.
CPF216B
Library &1 cannot be cleared.
CPF2161
Cannot delete some objects in library &1.
CPF2173
Value for ASPDEV not valid with special value for library.
CPF218C
&1 not a primary or secondary ASP.
CPF2182
Not authorized to library &1.
CPF8122
&8 damage on library &4.
CPF9814
Device &1 not found.
CPF9825
Not authorized to device &1.
CPF9833
*CURASPGRP or *ASPGRPPRI specified and thread has no ASP group.