COPY bind option
The COPY option copies an existing package or service, and names that package or service.
Command option | Option values | Used with |
---|---|---|
COPY |
|
Copying the package or service recalculates the access paths in the copy.
To create a remote copy, this option copies SQL statements from a package at your local server.
Therefore, you must hold the COPY privilege or its equivalent at the local server.
Option descriptions for COPY
- COPY(collection-id)
The name of the collection that contains the package or service to copy, as listed in column COLLID of catalog table SYSPACKAGE or DSNSERVICE.
collection-id can be an undelimited or a delimited identifier. The delimiter for collection-id is double quotation marks ("). If collection-id is delimited, Db2 does not convert the value to uppercase. A delimited collection-id can include letters, digits, or special characters other than a period (.) or blank.
- COPY(package-id)
- The name of the package to copy, as listed in column NAME of catalog table SYSPACKAGE.
package-id can be an undelimited or a delimited identifier. The delimiter for package-id is double quotation marks ("). If package-id is delimited, Db2 does not convert the value to uppercase. A delimited package-id can include letters, digits, or special characters other than a period (.) or blank.
COPY(service-name)
The name of the service to be copied , as listed in column NAME of catalog table DSNSERVICE.
service-name can be an unlimited or delimited identifier. The deliminator for service-name is double quotation marks ("). If service-name is delimited, Db2 does not convert the value to uppercase.
- \COPYVER(version-id)
An optional specification that determines the version of the package or service to copy. For packages, the default version for version-id is the empty string. For services, the default for version-id is the default service version.
version-id is an undelimited identifier. Db2 does not convert the value to uppercase or change it in any other way.
copy-options
Specifies which bind options are used for the new package or service.
- OPTIONS(COMPOSITE)
The option values that are specified in the BIND PACKAGE COPY subcommand are used for the package copy. The values for the BIND options that are not specified, except the values of ENABLE, DISABLE, OWNER, and QUALIFIER, are the BIND option values that are in the SYSPACKAGE catalog table row that describes the source package that is to be copied.
The option values that are specified in the BIND SERVICE COPY subcommand are used for the service copy. The values for the BIND options that are not specified, except the values of ENABLE, DISABLE, OWNER, and QUALIFIER, are the BIND option values that are in the DSNSERVICE and SYSPACKAGE catalog table row that describes the source service that is to be copied.
For BIND SERVICE, the server must be Db2 12 for z/OS® or later.
- OPTIONS(COMMAND)
The option values that are specified in the BIND PACKAGE COPY or BIND SERVICE COPY subcommand are used for the package or service copy.
The values for options that are not specified are determined as follows:
- For a local copy, the Db2-defined BIND PACKAGE or BIND SERVICE options defaults are used.
For a remote copy, the server-defined BIND PACKAGE or BIND SERVICE option defaults are used at the server.
For BIND PACKAGE, you must use OPTIONS(COMMAND) when copying to a down-level server or to a non-z/OS Db2 server. A down-level server is any server that is not Db2 12 for z/OS.
1For BIND SERVICE, the server must be Db2 12 for z/OS or later.
Restrictions for COPY
- collection-id.package-id must identify a package on the local server.
collection-id.service-name must identify a service on the local server.
You cannot copy to a package or service in the same collection. If you make the copy on the local server, collection-id. on the COPY option must not name the collection used on the PACKAGE or SERVICE option.
When the LOCAL date or time format is in effect at the local site, and you use the COPY option to bind a copy of a local package at a remote site, Db2 uses the ISO format for output values in the remote package unless the SQL statement explicitly specifies a different format. Input values in the remote package can be in one of the standard formats, or in a format that is recognized by the server's local date/time exit.
The following options are mutually exclusive with the COPY option for BIND SERVICE: NAME, VERSION, SQLDDNAME, SQLENCODING, DATE, TIME, DEC, DECDEL, STRDEL.
Default values for COPY
Process | Default value |
---|---|
BIND PLAN | N/A |
BIND PACKAGE | None |
![]() ![]() |
![]() ![]() |
REBIND PLAN | N/A |
REBIND PACKAGE | N/A |
COPY has no default. If you do not use COPY, you must use MEMBER for BIND PACKAGE or NAME for BIND SERVICE. You cannot use both options.
Copying packages to remote servers
To copy and bind packages from Db2 12 for z/OS to some other server that does not support all the new BIND options in Db2 12, use the OPTIONS(COMMAND) option on BIND PACKAGE COPY. Any options you do not explicitly specify on the BIND PACKAGE subcommand are set to the server's defaults. Using this option can prevent bind errors when you bind and copy packages to servers other than Db2 12 for z/OS.
BIND PACKAGE for remote SQL
- Target location as the target site on the CONNECT/implicit DRDA SQL
- Collection ID as the native SQL procedure's schema
- Package ID as the native SQL procedure's name
- COPYVER as the native SQL procedure's version
CREATE PROCEDURE TEST.MYPROC LANGUAGE SQL VERSION ABC ...
BEGIN
...
CONNECT TO SAN_JOSE
...
END
BIND PACKAGE(SAN_JOSE.TEST) COPY(TEST.MYPROC) COPYVER(ABC) ACTION(ADD)
BIND PACKAGE with SET CURRENT PACKAGESET and SET CURRENT PACKAGE PATH
- Target collection ID as the target of the SQL statements
- Source collection ID as the native SQL procedure's schema
- Package ID as the native SQL procedure's name
- COPYVER as the native SQL procedure's version
For example, to use the SQL statement SET CURRENT PACKAGESET with the BIND PACKAGE command , issue:
CREATE PROCEDURE TEST.MYPROC LANGUAGE SQL VERSION ABC ...
BEGIN
...
SET CURRENT PACKAGESET = 'COLL2'
...
END
BIND PACKAGE(COLL2) COPY(TEST.MYPROC) COPYVER(ABC)
ACTION(ADD) QUALIFIER(XYZ)
If you need to create a new copy because the native SQL procedure has changed and requires a regeneration, use the BIND COPY ACTION(REPLACE) command.
Catalog records for COPY
See the COPY column in SYSPACKAGE catalog table.

Copying services to remote servers
When binding and copying a service to a remote server, both servers must be Db2 12 for z/OS or later.

The following example, copies the existing REST service payroll.getEmployeeSalary with a version-id of Ver2, to a remote server with the location-name PRODSYS.
The new service has the same collection-id as the original service. The QUALIFIER option is also specified for the new service which determines the implicit qualifier for unqualified names of tables, views, indexes, and aliases contained in the service created on the PRODSYS system. The DESCRIPTION option is used to describe the newly copied service.
BIND SERVICE(PRODSYS."payroll") COPY("payroll"."getEmployeeSalary") COPYVER(Ver2) QUALIFIER(PRODQUAL) DESCRIPTION('This is the PRODSYS copy of getEmployeeSalary')