Command reference / object
CRTDUPOBJ
Create Duplicate Object
Copies one object or a group of objects. It does not create an exact duplicate of files. A duplicate in the same library as the original must be given a new name; in a different library it can keep the original name. A group can be copied by generic name, *ALL, or several object types, which requires a different target library. Options control whether physical-file or save-file data is copied, and whether constraints, triggers, access controls and file and member identifiers are carried over. A duplicated logical file is based on the duplicated physical file only when the original logical and physical files were in the same library. The owner of the duplicate is the issuing user, or the group profile if that applies. Authorities mostly match the original.
Allowed environments: *ALL.
Positional parameters: 5.
Restrictions
- Requires *USE and *OBJMGT authority for the existing object.
- Requires *USE and *ADD authority for the library of the new object.
- Requires *AUTLMGT authority if the object is an authorization list.
- Requires *OBJOPR authority for CRTSAVF to create a duplicate save file. Its contents are copied when DATA(*YES) is specified.
- The duplicate is created in the same auxiliary storage pool (ASP) as the to-library.
- With DATA(*YES) on a file, the new file is locked for the copy's duration. Functions such as DSPFD, DSPOBJD, DSPRCDLCK and WRKOBJLCK should not be used on it until the copy completes.
- Duplicating a database or save file between ASP groups is not supported. Storage must be in the same ASP group, the system ASP (ASP 1), or a basic user ASP (ASPs 2-32).
- Duplicate names of *GSS, *FNTRSC, *FORMDF, *OVL, *CSI, *PAGDFN and *PAGSEG objects cannot exceed 8 characters.
- *USRSPC and *USRIDX objects can be copied only into libraries permitted by the QALWUSRDMN system value, unless the object was created as a system domain object.
Parameters
OBJ
From object
Names one or more objects to duplicate: a specific name, a generic name ending in an asterisk, or all objects. This parameter is required.
Suggested / special values:
*ALL
*ALL- All objects of the specified type in the library for which you have authority are duplicated.
FROMLIB
From library
Names the library that contains the objects to duplicate. This parameter is required.
Suggested / special values:
*LIBL, *CURLIB
*LIBL- Search the library list for the first match. Valid only for a specific object and a single object type.
*CURLIB- Use the current library for the thread, or QGPL if none is set.
OBJTYPE
Object type
Sets the type of object to duplicate, as one value or a list. This parameter is required.
Allowed values:
*ALL, *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
*ALL- All object types with the specified name that you have authority to are duplicated.
TOLIB
To library
Names the library in which the duplicate object is created.
Suggested / special values:
*FROMLIB, *SAME, *CURLIB
*FROMLIB- The new object is in a library with the same name as the original's library.
*SAME- Same meaning as *FROMLIB.
*CURLIB- The current library for the thread receives the new object, or QGPL if none is set.
NEWOBJ
New object
Names the new object. Required when the to-library is the same library and the same ASP device is given for both ASPDEV and TOASPDEV. Member names in a duplicated database file stay the same.
Suggested / special values:
*OBJ, *SAME
*OBJ- The new object has the same name as the original; the libraries must differ.
*SAME- Same meaning as *OBJ.
ASPDEV
From ASP device
Names the ASP device where storage is allocated for the From library, when that library is not in the thread's library name space.
Suggested / special values:
*, *CURASPGRP, *SYSBAS
*- Search the ASPs in the thread's library name space.
*CURASPGRP- Search the primary and secondary ASPs in the thread's ASP group. Errors if the thread has no ASP group.
*SYSBAS- Search ASP 1 and basic user ASPs 2-32 only.
TOASPDEV
To ASP device
Names the ASP device where storage is allocated for the To library, when that library is not in the thread's library name space.
Suggested / special values:
*ASPDEV, *CURASPGRP, *SYSBAS
*ASPDEV- Use the ASP device given for the ASPDEV parameter.
*- Search the ASPs in the thread's library name space.
*CURASPGRP- Search the primary and secondary ASPs in the thread's ASP group. Errors if the thread has no ASP group.
*SYSBAS- Search ASP 1 and basic user ASPs 2-32 only.
DATA
Duplicate data
Sets whether data records in database physical files or save files are copied. Members of physical files are copied either way.
Allowed values:
*NO, *YES
*NO- Data records are not copied.
*YES- Data records are copied to the new object.
CST
Duplicate constraints
Sets whether constraints on existing database physical files are copied to the new files. Not used for other objects.
Allowed values:
*YES, *NO
*YES- Constraints are copied.
*NO- Constraints are not copied.
TRG
Duplicate triggers
Sets whether triggers on existing database files are copied to the new files. Not used for other objects; the trigger program's library affects the result.
Allowed values:
*YES, *NO
*YES- Triggers are copied.
*NO- Triggers are not copied.
FILEID
Duplicate file identifiers
Sets whether the file and member level identifiers of the existing database file are reused. Not used for other objects.
Allowed values:
*NO, *YES
*NO- The system generates new identifiers for the new file.
*YES- The existing identifiers are used. Use only when an exact duplicate is expected, since duplicate identifiers can affect database operations.
ACCCTL
Duplicate access control
Sets whether row and column access controls on existing database physical files are copied. Not used for other objects.
Allowed values:
*ALL, *ROW, *COL, *NONE
*ALL- Both row and column access controls are copied.
*ROW- Only row access controls are copied.
*COL- Only column access controls are copied.
*NONE- Neither is copied. Requires DATA(*NO) if the file has active permissions or masks.
Examples
CRTDUPOBJ OBJ(FILEA) FROMLIB(LIB1) OBJTYPE(*FILE) TOLIB(LIB2) DATA(*YES)
Duplicates file FILEA from LIB1 into LIB2, with its data, constraints and triggers. Authorities carry over, and new file and member level identifiers are generated.
CRTDUPOBJ OBJ(FILEB) FROMLIB(LIB3) OBJTYPE(*FILE) NEWOBJ(FILEDUP) DATA(*NO) CST(*NO) TRG(*NO) FILEID(*YES)
Duplicates FILEB in the same library as FILEDUP, without data, constraints or triggers, and keeps the original identifiers.
Generated from os/cl/catalog/CRTDUPOBJ.json and os/cl/help/CRTDUPOBJ.json.