Delete Object (DLTOBJ)

The Delete Object (DLTOBJ) command can be used to delete objects of an object type listed in the object type (OBJTYPE) parameter. Many, but not all, of the library-based external objects on the system can be deleted using this command. A few of the DLTxxx commands for supported object types allow an additional parameter to be specified in addition to the object name and library name. For example, the DLTF, DLTIMGCLG and DLTJRNRCV commands support additional parameters for deleting *FILE, *IMGCLG and *JRNRCV object types. For those object types, this command does not allow you to specify those additional parameters. Therefore, the DLTxxx command should be used when object specific parameters are needed for deleting the object.

The DLTOBJ command has some advantages over the DLTxxx commands:

For information about the object and library authorities and locks refer to the Delete Object (QLIDLTO) API in the APIs topic collection in the Programming category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/. The QLIDLTO API is the command processing program (CPP) for this command.

Restrictions:

Parameters

Keyword Description Choices Notes
OBJ Object Qualified object name Required, Positional 1
Qualifier 1: Object Generic name, name, *ALL
Qualifier 2: Library Name, *LIBL, *CURLIB, *USRLIBL, *ALL, *ALLUSR
OBJTYPE Object type *ALRTBL, *AUTL, *BNDDIR, *CFGL, *CHTFMT, *CLD, *CLS, *CMD, *CNNL, *COSD, *CRQD, *CSI, *CSPMAP, *CSPTBL, *CTLD, *DEVD, *DTAARA, *DTADCT, *DTAQ, *EDTD, *FCT, *FILE, *FNTRSC, *FNTTBL, *FORMDF, *FTR, *GSS, *IGCDCT, *IGCSRT, *IGCTBL, *IMGCLG, *IPXD, *JOBD, *JOBQ, *JRN, *JRNRCV, *LIB, *LIND, *LOCALE, *MEDDFN, *MENU, *MGTCOL, *MODD, *MODULE, *MSGF, *MSGQ, *NODGRP, *NODL, *NTBD, *NWID, *NWSCFG, *NWSD, *OUTQ, *OVL, *PAGDFN, *PAGSEG, *PDFMAP, *PDG, *PGM, *PNLGRP, *PSFCFG, *QMFORM, *QMQRY, *QRYDFN, *SBSD, *SCHIDX, *SPADCT, *SQLPKG, *SQLUDT, *SQLXSR, *SRVPGM, *SSND, *TBL, *TIMZON, *USRIDX, *USRQ, *USRSPC, *VLDL, *WSCST Required, Positional 2
ASPDEV ASP device Name, *, *ALLAVL, *CURASPGRP, *SYSBAS Optional
RMVMSG Remove message *NO, *YES Optional

Object (OBJ)

Specifies the objects which you want to delete and the library or libraries from which the objects are to be deleted.

This is a required parameter.

Qualifier 1: Object

*ALL
All objects of the specified object type are deleted from the specified library or libraries. When *ALL is specified for the object name, the library name must be a specific library name (it cannot be a special value).

Note: System library names such as library QSYS are allowed, but be very careful about specifying a system library name with an object name of *ALL.

generic-name
A generic name is a character string that contains one or more characters (the prefix) followed by an asterisk (*). When a generic name is specified, all objects of the specified object type that have names with the same prefix as the generic name are deleted from the specified library or libraries.
name
Specify the name of the object to be deleted.

Qualifier 2: Library

*LIBL
All libraries in the library list for the current thread are searched until the first match is found. If a specific object name is specified (instead of a generic name or *ALL), only the first object found with that name is deleted. If the ASP device (ASPDEV) parameter is specified when this value is used, ASPDEV(*) is the only valid value.
*CURLIB
The current library for the thread is searched. If no library is specified as the current library for the thread, the QGPL library is searched. If the ASP device (ASPDEV) parameter is specified when this value is used, ASPDEV(*) is the only valid value.
*USRLIBL
If a current library entry exists in the library list for the current thread, the current library and the libraries in the user portion of the library list are searched. If there is no current library entry, only the libraries in the user portion of the library list are searched. If a specific object name is specified (instead of a generic name or *ALL), only the first object found with that name is deleted. If the ASP device (ASPDEV) parameter is specified when this value is used, ASPDEV(*) is the only valid value.
*ALL
All the libraries in the auxiliary storage pools (ASPs) specified for the ASP device (ASPDEV) parameter are searched. All objects matching the specified name and object type in all libraries are deleted.
*ALLUSR
All user libraries in the auxiliary storage pools (ASPs) defined by the ASP device (ASPDEV) parameter are searched.

User libraries are all libraries with names that do not begin with the letter Q except for the following:

#CGULIB     #DSULIB     #SEULIB
#COBLIB     #RPGLIB
#DFULIB     #SDALIB

Although the following libraries with names that begin with the letter Q are provided by IBM, they typically contain user data that changes frequently. Therefore, these libraries are also considered user libraries:

QDSNX       QRCLxxxxx   QUSRDIRDB   QUSRVI
QGPL        QSRVAGT     QUSRIJS     QUSRVxRxMx
QGPL38      QSYS2       QUSRINFSKR
QMGTC       QSYS2xxxxx  QUSRNOTES
QMGTC2      QS36F       QUSROND
QMPGDATA    QUSER38     QUSRPOSGS
QMQMDATA    QUSRADSM    QUSRPOSSA
QMQMPROC    QUSRBRM     QUSRPYMSVR
QPFRDATA    QUSRDIRCF   QUSRRDARS
QRCL        QUSRDIRCL   QUSRSYS

  1. 'xxxxx' is the number of a primary auxiliary storage pool (ASP).
  2. A different library name, in the format QUSRVxRxMx, can be created by the user for each previous release supported by IBM to contain any user commands to be compiled in a CL program for the previous release. For the QUSRVxRxMx user library, VxRxMx is the version, release, and modification level of a previous release that IBM continues to support.
name
Specify the library where the object or objects are located.

Object type (OBJTYPE)

Specifies the type of object which you want to delete.

To see a complete list of object types when prompting this command, position the cursor on the field for this parameter and press F4 (Prompt). For a description of the object types, see "Object types" in the CL topic collection in the Programming category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.

This is a required parameter.

object-type
Specify the object type of the object to be deleted.

ASP device (ASPDEV)

Specifies the auxiliary storage pool (ASP) device name where storage is allocated for the library containing the object. If the library resides in an ASP that is not part of the thread's library name space, this parameter must be specified to ensure the correct library is searched. If this parameter is used when the library qualifier specified for the Object (OBJ) parameter is *CURLIB, *LIBL, or *USRLIBL, 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, the primary and secondary ASPs in the thread's ASP group.
*ALLAVL
All available ASPs will be searched. This includes the system ASP (ASP 1), all defined basic user ASPs (ASPs 2-32), and all available primary and secondary ASPs (ASPs 33-255 with a status of 'Available'). The ASP groups are searched in alphabetical order by the primary ASP. The system ASP and all defined basic user ASPs are searched after the ASP groups. ASPs and libraries to which the user is not authorized are bypassed and no authority error messages are sent.
*CURASPGRP
If the thread has an ASP group, the primary and secondary ASPs in the thread's 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. If no ASP group is associated with the thread an error will be issued.
*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. 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.

Remove message (RMVMSG)

Specifies whether or not to remove completion and informational messages related to the deletion of objects from the job log. Messages are only removed if the object was successfully deleted. Diagnostic and escape messages are not removed for objects that could not be deleted.

*NO
Do not remove the completion and informational messages related to the deletion of objects from the job log.
*YES
When the delete is successful, remove the completion and informational messages related to the deletion of objects from the job log.

Examples

Example 1: Delete all user spaces in a library

DLTOBJ OBJ(MYLIB/*ALL) OBJTYPE(*USRSPC) ASPDEV(*) RMVMSG(*NO)

This command deletes all of the user spaces from the library MYLIB if the user has the proper authority for the user spaces and the library.

Example 2: Delete all libraries of a generic name on the system

DLTOBJ OBJ(QSYS/TESTLIBXY*) OBJTYPE(*LIB) ASPDEV(*ALLAVL)

This command deletes all libraries that have a name starting with TESTLIBXY on all available ASPs if the user has the proper authority.

Error messages

CPFA030
Object already in use.
CPFB8ED
Device description &1 not correct for operation.
CPF210F
Operation not successful for &1 in &2 type *&3.
CPF2105
Object &1 in &2 type *&3 not found.
CPF2110
Library &1 not found.
CPF2113
Cannot allocate library &1.
CPF2114
Cannot allocate object &1 in &2 type *&3.
CPF2117
&4 objects type *&3 deleted. &5 objects not deleted.
CPF211A
Object *ALL not allowed for library &1.
CPF2125
No objects deleted.
CPF2166
Library name &1 not valid.
CPF2173
Value for ASPDEV not valid with special value for library.
CPF2176
Library &1 damaged.
CPF2182
Not authorized to library &1.
CPF2189
Not authorized to object &1 in &2 type *&3.
CPF21B7
Not all objects of type *&3 deleted
CPF21B8
&4 *&3 objects in ASP group &6 deleted; &5 not deleted.
CPF21B9
No objects in ASP group &4 deleted.
CPF218C
&1 not a primary or secondary ASP.
CPF24B4
Severe error while addressing parameter list.
CPF2605
Not able to allocate &1.
CPF9802
Not authorized to object &2 in &3.
CPF9803
Cannot allocate object &2 in library &3.
CPF9814
Device &1 not found.
CPF9820
Not authorized to use library &1.
CPF9825
Not authorized to device &1.
CPF9833
*CURASPGRP or *ASPGRPPRI specified and thread has no ASP group.