Where allowed to run: All environments (*ALL) Threadsafe: No |
Parameters Examples Error messages |
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:
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. More information on handling errors is in the Files and file systems topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
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. More information on preventing status messages from appearing is in the Files and file systems topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter.
Performance:
To increase the performance of the copy:
Notes For Delimited Data:
Notes For Fixed Data: The information for each field of the fixed format file must be in the following order:
Field Starting Ending Null Name Position Position Character Position _________________________________________________________ Field1 1 10 11 Field2 12 15 16 *END
The information for this Field Definition File would be:
The Field Definition File for the above example would be:
Field1 1 10 11 Field2 12 15 16 *END
An example of the corresponding file above Field Definition File using *COL:
*COL 1 10 11 *COL 12 15 16 *END
Notes For LOB data fields:
LOB data fields require the use of secondary stream files that contain the LOB data and a Field Definition File that describes the offsets of the fields in the data file. Each record that represents a LOB in the import file contains the name of a secondary stream file, instead of the data.
Note: In the following example, there are 3 secondary stream files (lob1.dat, lob2.dat, and lob3.dat) inside of the directory "/lobdata", which contain the actual LOB data to import.
Using the following FDF:
Field Starting Ending Null Name Position Position Character Position _________________________________________________________ Field1 1 10 42 Field2 12 40 44 *END
The import file would be 44 characters (based on the above FDF) in record length, containing the following data:
0 1 2 3 4 /Character 12345678901234567890123456789012345678901234 /Position aaaaaaaaaa /lobdata/lob1.dat N N bbbbbb /lobdata/lob2.dat N N /lobdata/lob3.dat Y N cccccccccc N Y
Restrictions:
Top |
Keyword | Description | Choices | Notes |
---|---|---|---|
FROMSTMF | From stream file | Path name | Optional, Positional 2 |
FROMFILE | From file | Element list | Optional, Positional 3 |
Element 1: File | Qualified object name | ||
Qualifier 1: File | Name | ||
Qualifier 2: Library | Name, *LIBL, *CURLIB | ||
Element 2: Member | Name, *FIRST, *ALL | ||
TOFILE | To data base file | Element list | Required, Positional 1 |
Element 1: File | Qualified object name | ||
Qualifier 1: File | Name | ||
Qualifier 2: Library | Name, *LIBL, *CURLIB | ||
Element 2: Member | Name, *FIRST, *FROMMBR, *ALL | ||
MBROPT | Replace or add records | *ADD, *REPLACE, *UPDADD | Optional |
STMFLEN | Stream file record length | Integer, *TOFILE | Optional |
FROMCCSID | From CCSID | 1-65533, *FILE | Optional |
TOCCSID | To CCSID | 1-65533, *FILE | Optional |
RCDDLM | Record delimiter | Character value, *ALL, *CRLF, *LF, *CR, *LFCR, *EOR | Optional |
DTAFMT | Record format of import file | *DLM, *FIXED | Optional |
STRDLM | String delimiter | Character value, *DBLQUOTE, *NONE | Optional |
STRESCCHR | String escape character | Character value, *STRDLM, *NONE | Optional |
RMVBLANK | Remove blanks | *NONE, *LEADING, *TRAILING, *BOTH | Optional |
FLDDLM | Field delimiter | Character value, ',', *TAB | Optional |
FLDDFNFILE | Field definition file | Element list | Optional |
Element 1: File | Qualified object name | ||
Qualifier 1: File | Name | ||
Qualifier 2: Library | Name, *LIBL, *CURLIB | ||
Element 2: Member | Name, *FIRST, *ALL | ||
DECPNT | Decimal point | *PERIOD, *COMMA | Optional |
DATFMT | Date format | *ISO, *USA, *EUR, *JIS, *MDY, *DMY, *YMD, *JUL, *YYMD | Optional |
DATSEP | Date separator | '/', '-', '.', ',', *BLANK | Optional |
TIMFMT | Time format | *ISO, *USA, *EUR, *JIS, *HMS | Optional |
TIMSEP | Time separator | ':', '.', *BLANK | Optional |
FROMRCD | Copy from record number | Element list | Optional |
Element 1: Copy from record number | Unsigned integer, *FIRST | ||
Element 2: Number of records to copy | Unsigned integer, *END | ||
ERRLVL | Errors allowed | Unsigned integer, *NOMAX | Optional |
ERRRCDFILE | Error record file | Single values: *NONE Other values: Element list |
Optional |
Element 1: File | Qualified object name | ||
Qualifier 1: File | Name | ||
Qualifier 2: Library | Name, *LIBL, *CURLIB | ||
Element 2: Member | Name, *FIRST, *ALL | ||
ERRRCDOPT | Replace or add records | *ADD, *REPLACE | Optional |
RPLNULLVAL | Replace null values | *NO, *FLDDFT | Optional |
IDCOL | Identity column | *GEN, *FROMFLD | Optional |
Top |
Specifies the path name of the stream file from which data is to be copied. Either this parameter or the FROMFILE parameter is required.
Top |
Specifies the from-file and file member that contains the records to be copied. Either this parameter or the FROMSTMF parameter is required.
The from-file can be any of the following file types:
Element 1: File
Qualifier 1: File
Qualifier 2: Library
Element 2: Member
Top |
Specifies the output database file and member to receive the copied records. The output file is also referred to as the to-file .
The to-file can be any of the following file types:
This is a required parameter.
Element 1: File
Qualifier 1: File
Qualifier 2: Library
Element 2: Member
Top |
Specifies whether the copy operation replaces, adds, or updates the records in a database file member if a member with the specified name already exists. If the member does not exist, it is created and added to the database file.
Note: If *ADD or *UPDADD is specified and the to-file contains no records, the copy operation completes normally. If *REPLACE is specified and the to-file contains no records, the copy operation ends abnormally.
Top |
The maximum record length of any record of the stream file when *DLM is specified for the Record format of import file (DTAFMT) parameter, or the actual record length of all the records of the stream file when *FIXED is specified for the DTAFMT parameter.
Top |
Specifies the coded character set identifier (CCSID) of the from-file.
Top |
Specifies the coded character set identifier (CCSID) to use for the to-file fields.
Top |
Specifies the record delimiter to be used.
If the FROMFILE parameter is specified, valid values are *EOR or a character value. If the FROMSTMF parameter is specified, valid values are *CR, *CRLF, *LF, *LFCR or *ALL.
Top |
Specifies the format of the data in the from-file.
Top |
Specifies the string delimiter for the data of the fields being copied from. This character indicates the start and end of character, date, time, and timestamp strings in the from-file. Depending on the utility used to create the from-file, some types of strings may appear in the from-file without string delimiter characters.
The specified delimiter character will be converted from the coded character set identifier (CCSID) of the job to the CCSID of the from-file.
Top |
Specifies the character to be looked for within string fields in the from-file. Character fields in the from-file may contain characters that have a special meaning to CPYFRMIMPF. These characters include the string delimiter and the string escape character itself. As a result, CPYFRMIMPF could misinterpret the data and produce unexpected results.
The string escape character precedes such characters in the data and revokes their special meaning. CPYFRMIMPF can then determine if the character is data or a string delimiter. The escape characters are not imported into the to-file.
This parameter describes the method that the export utility used for character fields that contained the string escape character or string delimiter.
The specified string escape character will be converted from the coded character set identifier (CCSID) of the job to the CCSID of the from-file. If the from-file CCSID is 1200, 1208, or 13488 the string escape character is converted to the job CCSID, or the job's default CCSID when the job CCSID is 65535.
Top |
Specifies whether blanks are removed or retained.
Top |
Specifies the field delimiter for the record being copied from. This value is used to determine where one field ends and the next field begins.
Top |
Specifies the field definition file which defines the format of the data when *FIXED is specified for the Record format of import file (DTAFMT) parameter. If DTAFMT(*FIXED) is specified, this parameter is required.
The field definition file can be any of the following file types:
Element 1: File
Qualifier 1: File
Qualifier 2: Library
Element 2: Member
Top |
Specifies the decimal point character to be used when copying numeric data from the from-file.
Top |
Specifies the date format to be used when copying date fields from the from-file.
Top |
Specifies the date separator for the date format. The separator is ignored for DATFMT of *ISO, *USA, *EUR, and *JIS because these formats have a fixed date separator.
Top |
Specifies the time format to be used when copying time fields from the from-file.
Top |
Specifies the time separator for the time format. This parameter is ignored if *ISO, *USA, *EUR, or *JIS is specified for the Time format (TIMFMT) parameter because those time formats define the required time separator character.
Top |
Specifies which records are copied from the from-file.
Element 1: Copy from record number
Element 2: Number of records to copy
Top |
Specifies the maximum number of recoverable read or write errors for the to-file that are tolerated during the copy operation.
Top |
Specifies the database file where the records that are in error should be written.
The error record file can be any of the following file types:
Single values
Element 1: File
Qualifier 1: File
Qualifier 2: Library
Element 2: Member
Top |
Specifies how error records are added to the error record file.
Top |
Specifies whether null field values will be replaced when copying import file records.
Top |
Specifies, if the to-file is an SQL table which contains a column with the IDENTITY attribute or a column with the ROWID data type, whether the value for the column will be generated by the system or the default value is used.
Top |
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.
Top |
Top |