Where allowed to run: All environments (*ALL) Threadsafe: Yes |
Parameters Examples Error messages |
The Create Duplicate Object (CRTDUPOBJ) command copies a single object or a group of objects. It does not create an exact duplicate of files. The new object must be renamed if it is created in the library that contains the original object. The newly-created object can retain the name of the original object if it is created in a library different than the one that contains the original object. You can copy a group of related objects by specifying a generic object name or by specifying *ALL or more than one object type. When copying a group of related objects, you must specify a different library in which the new objects are created. You can specify whether data in physical files or save files is copied. You can also specify whether any constraints or triggers associated with an existing database file are to be associated with the newly-created file and whether the file level and member level identifiers of an existing database file are to be copied to the newly-created database file.
Note: The value of the Create authority (CRTAUT) parameter specified on the Create Library (CRTLIB) command for the to-library is not used for the duplicate object. The public and private authorities for the duplicate object will be the same as the original object with the following exception. If, by not duplicating an INSTEAD OF trigger, the new database file loses the insert, update, or delete capability of the old file, then the corresponding insert, update, or delete authorities on the old file will not be granted to the new file. The owner of the duplicate object is either the user profile of the user who issues the command or the group profile if the user profile of the user who issues the command is a member user profile that has specified that the group profile should be the owner.
When duplicating a file using the CRTDUPOBJ command, the format of the existing file specified for the From object (OBJ) parameter is shared with the newly-created file specified for the New object (NEWOBJ) parameter. When the maximum number (approximately 32K) of file objects that share the same format has been reached, the newly-created file will create a new format instead of sharing the FROM file's format.
Note: All of the files that share the same format will be considered related and will be grouped together in the same save list when a save operation is performed.
When a logical file is copied into another library, two cases determine the basing for the file:
When the CRTDUPOBJ command creates a database file, you can use the Duplicate constraints (CST) parameter to specify whether or not any constraints associated with the existing file are to be associated with the newly-created file. Similarly, you can use the Duplicate triggers (TRG) parameter to specify whether or not any triggers associated with the existing file are to be associated with the newly-created file. Note that there are special considerations of which to be aware relating to the duplication of triggers. For example, the duplication will differ depending on whether or not the trigger program associated with the existing file was in the same library as the existing file. You can also use the Duplicate file identifiers (FILEID) parameter to specify whether or not the file level and member level identifiers of the existing file will be used for the newly-created file.
Note: For additional information, see the Database category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.
When the object being duplicated is an object type which is eligible to be journaled, there are two methods for the object to automatically start journaling after the object has been created.
Note: The QDFTJRN data area overrides the journaling state and journal inherit rules of the target library.
Note: Support of the QDFTJRN data area will be discontinued in a future release.
Use the Display Library Description (DSPLIBD) command to display journal information for the library. Refer to the Start Journal Library (STRJRNLIB) command for more information about journaling a library.
Note: For additional information regarding journaling, see the Journal management topic collection in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.
Restrictions:
Top |
Keyword | Description | Choices | Notes |
---|---|---|---|
OBJ | From object | Generic name, name, *ALL | Required, Positional 1 |
FROMLIB | From library | Name, *LIBL, *CURLIB | Required, Positional 2 |
OBJTYPE | Object type | Single values: *ALL Other values (up to 57 repetitions): *ALRTBL, *AUTL, *BNDDIR, *CHTFMT, *CLD, *CLS, *CMD, *CRQD, *CSI, *CSPMAP, *CSPTBL, *DTAARA, *FCT, *FILE, *FNTRSC, *FNTTBL, *FORMDF, *FTR, *GSS, *IGCDCT, *IGCSRT, *JOBD, *JOBQ, *LOCALE, *MEDDFN, *MENU, *MGTCOL, *MODULE, *MSGF, *MSGQ, *M36CFG, *NODGRP, *NODL, *OUTQ, *OVL, *PAGDFN, *PAGSEG, *PDFMAP, *PDG, *PGM, *PNLGRP, *PRDAVL, *PRDDFN, *PRDLOD, *PSFCFG, *QMFORM, *QMQRY, *QRYDFN, *SBSD, *SCHIDX, *SRVPGM, *SSND, *TBL, *USRIDX, *USRSPC, *VLDL, *WSCST |
Required, Positional 3 |
TOLIB | To library | Name, *FROMLIB, *SAME, *CURLIB | Optional, Positional 4 |
NEWOBJ | New object | Name, *OBJ, *SAME | Optional, Positional 5 |
ASPDEV | From ASP device | Name, *, *CURASPGRP, *SYSBAS | Optional |
TOASPDEV | To ASP device | Name, *ASPDEV, *, *CURASPGRP, *SYSBAS | Optional |
DATA | Duplicate data | *NO, *YES | Optional |
CST | Duplicate constraints | *YES, *NO | Optional |
TRG | Duplicate triggers | *YES, *NO | Optional |
FILEID | Duplicate file identifiers | *NO, *YES | Optional |
Top |
Specifies one or more objects to be duplicated.
This is a required parameter.
Top |
Specifies the library that contains the objects to be duplicated.
This is a required parameter.
Note: *LIBL can only be specified for a specific object and a single, specific object type.
Top |
Specifies the type of the object to be duplicated. This parameter can be specified as a single value or as a list of one or more object types.
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.
Single values
Other values
Top |
Specifies the library in which the duplicate object is to be created.
Note: If the library is in an auxiliary storage pool (ASP), the object to be duplicated must be a valid object type that can reside in an ASP. If this object type is not a valid type that can reside in an ASP, an error message is sent.
Top |
Specifies name of the new object. A name must be specified here if *SAME or *FROMLIB is specified for the To library (TOLIB) parameter and the same auxiliary storage pool device is specified for both the From ASP device (ASPDEV) parameter and the To ASP device (TOASPDEV) parameter. The names of members in a database file to be duplicated remain the same in the new file.
Top |
Specifies the auxiliary storage pool (ASP) device name where storage is allocated for the library containing the object to be duplicated (the From library (FROMLIB) parameter). If the library is in an ASP that is not part of the thread's library name space, this parameter must be specified to ensure the correct object is duplicated. If this parameter is used when *LIBL or *CURLIB is specified for the FROMLIB parameter, * is the only valid value.
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.
Top |
Specifies the auxiliary storage pool (ASP) device name where storage is allocated for the library to contain the new object (the To library (TOLIB) parameter). If the library is in an ASP that is not part of the thread's library name space, this parameter must be specified to ensure the object is duplicated into the correct library. If this parameter is used when *CURLIB is specified for the TOLIB parameter, either TOASPDEV(*) must be specified or TOASPDEV(*ASPDEV) must be specified and the From ASP device (ASPDEV) parameter must be *.
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.
Top |
Specifies whether the data records in database physical files or save files are copied to the new object. Members of database physical files are copied whether or not the data contained in them is copied.
NOTES:
Top |
Specifies whether any constraints associated with existing database physical files are copied to the newly-created files. The specified value is not used for objects which are not database physical files.
Top |
Specifies whether any triggers associated with existing database files are copied to the newly-created files. The specified value is not used for objects which are not database files.
Note: There are special considerations of which to be aware relating to the duplication of triggers. For example, the duplication will differ depending on whether or not the trigger program associated with the existing file was in the same library as the existing file. For additional information, see the Database category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.
Top |
Specifies whether the file level and member level identifiers of the existing database file will be used for the newly-created file. The specified value is not used for objects which are not database files.
Top |
Example 1: Duplicating a Database File Including the Data Records, Constraints, and Triggers
CRTDUPOBJ OBJ(FILEA) FROMLIB(LIB1) OBJTYPE(*FILE) TOLIB(LIB2) DATA(*YES)
The file named FILEA in library LIB1 is duplicated in library LIB2. Authorities granted for FILEA in library LIB1 are granted to FILEA created in library LIB2. The data records, constraints, and triggers associated with FILEA in library LIB1 are copied to FILEA created in library LIB2. New file level and member level identifiers will be generated for FILEA created in library LIB2. This means that the file level and member level identifiers for FILEA in library LIB2 will not be the same as the file level and member level identifiers for FILEA in library LIB1.
Example 2: Duplicating a Database File Without the Data Records, Constraints, and Triggers and Keeping the Same File Level and Member Level Identifiers
CRTDUPOBJ OBJ(FILEB) FROMLIB(LIB3) OBJTYPE(*FILE) NEWOBJ(FILEDUP) DATA(*NO) CST(*NO) TRG(*NO) FILEID(*YES)
The file named FILEB in library LIB3 is duplicated in library LIB3 as FILEDUP. The data records, constraints, and triggers associated with FILEB in library LIB3 are not copied to FILEDUP created in library LIB3. The file level and member level identifiers for FILEDUP created in library LIB3 will be the same as the file level and member level identifiers for FILEB in library LIB3. Authorities granted for FILEB are granted to the new FILEDUP created in library LIB3 with the following exception. If, by not duplicating an INSTEAD OF trigger, the new database file FILEDUP loses the insert, update, or delete capability of the old database file FILEB, then the corresponding insert, update, or delete authorities on the old database file FILEB will not be granted to the new database file FILEDUP.
Top |
*ESCAPE Messages
Top |