CL Command Reference - CPYFRMIMPF
CL Command List > CPYFRMIMPF Reference
Description:
The Copy From Import File (CPYFRMIMPF) command copies all or part of an import file to the TOFILE. The term import file is used to describe a file created for purposes of copying data between heterogeneous databases. The import file (FROMSTMF or FROMFILE parameter) is called the from-file for this command.
An important aspect of this command is its ability to copy the data in parallel. Parallelism is activated for files with at least 50,000 records. Records are not copied in parallel when the FROMSTMF is specified. By using the Change Query Attributes (CHGQRYA) command, the number of tasks used to perform the copy is determined by the DEGREE parameter of the CHGQRYA command. For the best performance in implementing this command, the number of tasks should be set to the number of CPUs + 1.
For example, if the system has two CPUs, specify CHGQRYA DEGREE(*NBRTASKS 3)
To use multiple tasks, you must have the Symmetric Multiprocessing Product (SMP) feature installed on the system.
When copying from a tape file, any file in library QTEMP, a distributed file, or a logical file, only one task will be used. See the CHGQRYA command for more information.
Some of the specific functions that can be performed by the CPYFRMIMPF command include the following:
. Copying a from-file to an externally-described physical file. The to-file must exist on the system before the copy can occur.
. Limiting the range of records copied based on starting and ending relative record numbers.
. Adding records to an existing file member or replacing the contents of a receiving file member (MBROPT parameter).
Error Handling: The escape message CPF2817 is sent for many different error conditions that can occur during a copy operation. At least one diagnostic message that indicates the specific error condition always comes before the escape message.
Overrides: Overrides are processed for all files.
Status Message: During the running of the CPYFRMIMPF command, message CPI2801 is sent as a status message informing the interactive user that a copy operation is occurring.
Performance:
To increase the performance of the copy:
1. Delete any logical keyed files based on the to-file.
2. Disable all constraints and triggers of the to-file.
3. Ensure the from-file records will be copied correctly by attempting to copy a few of the records, by using the FROMRCD and number of records option, before copying all the records.
4. Use the ERRLVL(*NOMAX) parameter after knowing the data can be copied correctly.
Notes For Delimited Data:
1. A delimiter can not be a blank(กฏ กฏ) character.
2. A blank(กฏ กฏ) can not be contained within a numeric field.
3. Fields in the from-file that are longer than the corresponding fields in the to-file will be truncated (on the right).
4. If the data of the from-file does not represent all the fields in the to-file, the fields of the to-file will be set to null. If this happens and the to-file fields do not allow a null value, an error will occur and the record will not be copied to the to-file.
5. A null field in the from-file can be specified by two adjacent field delimiters, two adjacent string delimiters or a field delimiter followed by a record delimiter.
6. From-file field of all blank characters to be stored in a fixed-length field in the to-file, will preserve blank characters even though removal blanks is specified.
7. From-file field of all blank characters to be stored in a variable-length field in the to-file, will be represented as only one significant blank character when removal blanks is specified.
Restrictions:
. The from-file and to-file cannot be the same file.
. The to-file must exist prior to the copy.
. The to-file will not have the same relative record numbers as the from-file.
. The from-file must be a source file, or a valid file with 1 field that is not a numeric data type.
. If the from-file is defined with the SHARE(*YES) option for the file, unpredictable results can occur. Therefore, if the file is defined with SHARE(*YES), the user should make sure the file is not opened by any process prior to the copy.
Examples:
Example 1: Copying Physical File Import File
CHGQRYA DEGREE(*NBRTASKS 3)
:
CPYFRMIMPF FROMFILE(IMPFILE) TOFILE(DB2FILE)
FLDDLM(กฏ;กฏ) RCDDLM(Xกฏ07กฏ)
DATFMT(*JIS) TIMFMT(*JIS)
The Change Query Attribute (CHGQRYA) is run prior to CPYFRMIMPF to allow the copy processing to be done by three tasks running in parallel.
All records of file IMPFILE will be copied to the externally-described physical file DB2FILE. Fields in the from-file are delimited by semi-colon (;) characters. Each record in the from file is delimited by a hexadecimal กฏ07กฏ character. Input date fields are are in yyyy-mm-dd format. Input time fields are in hh:mm:ss format.
Example 2: Copying Tape File Import File
OVRTAPF FILE(QTAPE) DEV(TAP02) SEQNBR(3)
:
CPYFRMIMPF FROMFILE(QTAPE) TOFILE(DB2WHS) ERRFILE(IMPERR)
The Override Tape File (OVRTAPF) parameter is run prior to CPYFRMIMPF to indicate that tape device TAP02 should be used for doing the copy. The from-file must be the third file on the tape mounted on TAP02.
All records of the from-file will be copied to the externally described physical file DB2WHS. Fields in the from-file are delimited by comma (,) characters. Input date fields are are in yyyy-mm-dd (ISO) format. Input time fields are in hh.mm.ss (ISO) format. From-file records that are found to contain errors and cannot be added to file DB2WHS are added to error file IMPERR.