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

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.

Type
*GENERIC
Required
Yes
Length
10
Case
Uppercase

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.

Type
*NAME
Required
Yes
Length
10
Case
Uppercase

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.

Type
*CHAR
Required
Yes
Length
7
List limit
57
Case
Uppercase

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.

Type
*NAME
Required
No
Default
*FROMLIB
Length
10
Case
Uppercase

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.

Type
*NAME
Required
No
Default
*OBJ
Length
10
Case
Uppercase

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.

Type
*NAME
Required
No
Default
*
Length
10
Case
Uppercase

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.

Type
*NAME
Required
No
Default
*ASPDEV
Length
10
Case
Uppercase

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.

Type
*CHAR
Required
No
Default
*NO
Length
4
Case
Uppercase

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.

Type
*CHAR
Required
No
Default
*YES
Length
4
Case
Uppercase

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.

Type
*CHAR
Required
No
Default
*YES
Length
4
Case
Uppercase

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.

Type
*CHAR
Required
No
Default
*NO
Length
4
Case
Uppercase

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.

Type
*CHAR
Required
No
Default
*ALL
Length
5
Case
Uppercase

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.

IBM command documentation

Generated from os/cl/catalog/CRTDUPOBJ.json and os/cl/help/CRTDUPOBJ.json.