COPY bind option

Start of changeThe COPY option copies an existing package or service, and names that package or service. End of change

Command option Option values Used with
COPY
  • ( collection-id.package-id )
  • ( collection-id.package-id ) COPYVER ( version-id )
  • ( collection-id.package-id ) COPYVER ( version-id ) copy-options
  • ( collection-id.package-id ) copy-options
  • Start of change( collection-id.service-name ) End of change
  • Start of change( collection-id.service-name ) COPYVER ( version-id )End of change
  • Start of change( collection-id.service-name ) COPYVER ( version-id ) copy-options End of change
  • Start of change( collection-id.service-name ) copy-options End of change

Start of change Copying the package or service recalculates the access paths in the copy.End of change

Start of changeTo create a remote copy, this option copies SQL statements from a package at your local server.End of change Therefore, you must hold the COPY privilege or its equivalent at the local server.

Option descriptions for COPY

(collection-id)
Start of changeThe name of the collection that contains the package or service to copy, as listed in column COLLID of catalog table SYSPACKAGE or DSNSERVICE.End of change

Start of changecollection-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.End of change

(package-id)
The name of the package to copy, as listed in column NAME of catalog table SYSPACKAGE.

Start of changepackage-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.End of change

Start of change(service-name)End of change
Start of change

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.

End of change
COPYVER(version-id)
Start of changeAn 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.End of change

Start of changeversion-id is an undelimited identifier. Db2 does not convert the value to uppercase or change it in any other way.End of change

Start of changecopy-optionsEnd of change
Start of changeStart of changeSpecifies which bind options are used for the new package or service.End of change
OPTIONS(COMPOSITE)
Start of changeThe 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.End of change

Start of changeThe 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.End of change

Start of change For BIND SERVICE, the server must be Db2 12 for z/OS or later.End of change

OPTIONS(COMMAND)
Start of changeThe option values that are specified in the BIND PACKAGE COPY or BIND SERVICE COPY subcommand are used for the package or service copy.End of change 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.
  • Start of changeFor a remote copy, the server-defined BIND PACKAGE or BIND SERVICE option defaults are used at the server.End of change 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. Start of change1For BIND SERVICE, the server must be Db2 12 for z/OS or later.End of change
End of change

Restrictions

  • collection-id.package-id must identify a package on the local server.
  • Start of change collection-id.service-name must identify a service on the local server.End of change
  • Start of changeYou 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.End of change
  • Start of changeWhen 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.End of change
  • Start of change The following options are mutually exclusive with the COPY option for BIND SERVICE: NAME, VERSION, SQLDDNAME, SQLENCODING, DATE, TIME, DEC, DECDEL, STRDEL.End of change

Default values for COPY

Process Default value
BIND PLAN N/A
BIND PACKAGE None
Start of changeBIND SERVICEEnd of change Start of changeNoneEnd of change
REBIND PLAN N/A
REBIND PACKAGE N/A

Start of changeCOPY 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.End of change

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

To execute SQL statements in the native SQL procedure after a CONNECT SQL statement or SQL statements that contain a three-part name from a remote server, you need a package at the target server. Use the BIND PACKAGE COPY command to specify the following:
  • 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
For example, to copy a version to a remote server using the BIND PACKAGE command, issue:
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

To use the SQL statements SET CURRENT PACKAGESET and SET CURRENT PACKAGE PATH, you must use the BIND PACKAGE COPY command to specify the following:
  • 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.

Start of change

Copying services to remote servers

Start of change When binding and copying a service to a remote server, both servers must be Db2 12 for z/OS or later. End of change

End of change

Start of changeThe following example, copies the existing REST service payroll.getEmployeeSalary with a version-id of Ver2, to a remote server with the location-name PRODSYS. End of change

Start of changeThe 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.End of change

    BIND SERVICE(PRODSYS."payroll") COPY("payroll"."getEmployeeSalary") COPYVER(Ver2) QUALIFIER(PRODQUAL) DESCRIPTION('This is the PRODSYS copy of getEmployeeSalary')