Copy To Import File (CPYTOIMPF)
Where allowed to run: All environments (*ALL) Threadsafe: No |
Parameters Examples Error messages |
The Copy To Import File (CPYTOIMPF) command copies an externally-described file to an import file. The term import file is used to describe a file created for purposes of copying data between heterogeneous databases. The import file (TOSTMF or TOFILE parameter) will be called the to-file for this command.
Some of the specific functions that can be performed by the CPYTOIMPF command include the following:
- Copying from an externally described physical file to the to-file (TOFILE or TOSTMF parameter).
- Adding records to an existing to-file member or replacing the contents of the to-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. More information on handling errors is in the Files and file systems category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.
Overrides: All overrides are in effect for this command. The parameters of the overrides that are supported by CPYTOIMPF are:
- FILE
- MBR
- OPNSCOPE
- SHARE
- LVLCHECK
- RCDFMTLCK
- SEQONLY
- INHWRT
- WAITRCD
- DSTDTA
- NBRRCDS
Status Message: During the running of the CPYTOIMPF command, message CPI2801 is sent as a status message informing the interactive user that a copy is occurring. More information on preventing status messages from appearing is in the Files and file systems category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.
Restrictions:
- During the time a CPYTOIMPF request is run, the file specified for the To data base file (TOFILE) parameter may be locked (similar to an *EXCL lock with no timeout) so that no access is possible.
- If the from-file has the SHARE(*YES) attribute, unpredictable results can occur. Therefore, if the from-file is defined with SHARE(*YES), the user should make sure the file is not opened by any process prior to the copy.
- If STMFAUT(*FILE) or STMFAUT(*INDIRFILE) is specified, the user must have the object management (*OBJMGT) authority over the database file and the stream file.
Note: Do not precede an entry with an asterisk unless that entry is a "special value" that is shown (on the display itself or in the help information) with an asterisk.
Top |
Parameters
Keyword | Description | Choices | Notes |
---|---|---|---|
FROMFILE | From 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, *ALL | ||
TOFILE | To data base file | Element list | Optional, Positional 2 |
Element 1: File | Qualified object name | ||
Qualifier 1: File | Name | ||
Qualifier 2: Library | Name, *LIBL, *CURLIB | ||
Element 2: Member | Name, *FIRST, *FROMMBR, *ALL | ||
TOSTMF | To stream file | Path name | Optional, Positional 3 |
MBROPT | Replace or add records | *ADD, *REPLACE | Optional |
FROMCCSID | From CCSID | 1-65533, *FILE | Optional |
TOCCSID | To CCSID | 1-65533, *FILE | Optional |
STMFCCSID | Stream file CCSID | 1-65533, *STMF, *PCASCII, *STDASCII | Optional |
STMFCODPAG | Stream file code page | 1-32767, *STMF, *PCASCII, *STDASCII | Optional |
STMFAUT | Stream file authority | *DFT, *INDIR, *FILE, *INDIRFILE | Optional |
RCDDLM | Record delimiter | Character value, *EOR, *CRLF, *LF, *CR, *LFCR | 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, *EOR | Optional |
FLDDLM | Field delimiter | Character value, ',', *TAB | Optional |
NULLIND | Null field indicator | *NO, *YES | Optional |
NUMFLDPAD | Numeric field pad | *NONE, *BLANK, *ZERO | Optional |
DECPNT | Decimal point | *PERIOD, *COMMA | Optional |
DATFMT | Date format | *ISO, *USA, *EUR, *JIS, *YYMD | Optional |
TIMFMT | Time format | *ISO, *USA, *EUR, *JIS | Optional |
ORDERBY | Order by | Character value, *NONE, *ARRIVAL | Optional |
ADDCOLNAM | Add column names | *NONE, *SQL, *SYS | Optional |
Top |
From file (FROMFILE)
Specifies the file that contains the records to be copied. The database file can be a single-format logical, physical, or multi-system file.
This is a required parameter.
Element 1: File
Qualifier 1: File
- name
- Specify the name of the file that contains the records to be copied.
Qualifier 2: Library
- *LIBL
- All libraries in the library list for the current thread are searched until the first match is found.
- *CURLIB
- The current library for the thread is searched. If no library is specified as the current library for the thread, the QGPL library is searched.
- name
- Specify the name of the library to be searched.
Element 2: Member
- *FIRST
- The first member (in order of creation date) in the specified from-file is used. Specifying *FIRST is not allowed if the from-file has no members.
- *ALL
- All members of the specified file are copied.
- name
- Specify the name of the from-file member containing the records to copy.
Top |
To data base file (TOFILE)
Specifies the database file to receive the copied records. Either this parameter or the TOSTMF parameter is required.
The to-file can be any of the following file types:
- source physical file
- program-described physical file
- externally-described physical file with one non-numeric field.
Element 1: File
Qualifier 1: File
- name
- Specify the name of the file to receive the copied records.
Qualifier 2: Library
- *LIBL
- All libraries in the library list for the current thread are searched until the first match is found.
- *CURLIB
- The current library for the thread is searched. If no library is specified as the current library for the thread, the QGPL library is searched.
- name
- Specify the name of the library to be searched.
Element 2: Member
- *FIRST
- The first member (in order of creation date) in the specified to-file is used.
Specifying *FIRST is not allowed if the specified to-file has no members and there is no override (OVRDBF command) in effect that specified a member name for the to-file.
- *ALL
- The data is copied to the correct to-member of the partitioned table. *ALL is only valid for partitioned tables.
- *FROMMBR
- Corresponding from-file and to-file member names are used.
- name
- Specify the name of the to-file member to receive the copied records. If a member with the specified name does not already exist in the to-file, the member will be added.
Top |
To stream file (TOSTMF)
Specifies the output stream file to which data is to be copied. Either this parameter or the TOFILE parameter is required. All directories in the path name must exist. New directories are not created. If the stream file does not exist, it will be created.
Note: The QSYS.LIB file system does not allow attributes to be set, so if the path name specified on the TOSTMF parameter is a QSYS member, diagnostic messages will appear in the joblog. The diagnostic messages will not prevent the copy operation from completing successfully.
- path-name
- Specify the path name of the output stream file to which data is to be copied.
Note: This parameter is Unicode-enabled. See "Unicode support in CL" in the CL topic collection in the Programming category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/ for additional information.
Top |
Replace or add records (MBROPT)
Specifies whether the copy operation replaces, adds, or fails to copy to the records in the to-file member if a member with the specified name already exists. If the member does not exist, it is created and added to the to-file.
Note: If *ADD 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.
Additional information is available in the Files and file systems category in the IBM i Information Center at http://www.ibm.com/systems/i/infocenter/.
- *ADD
- The copied records are added to the end of the existing member records.
- *REPLACE
- The copied records replace the existing member records.
Top |
From CCSID (FROMCCSID)
Specifies the coded character set identifier (CCSID) to use for the from-file fields.
- *FILE
- The data is converted from the from-file field CCSID. If the CCSID of the from-file field is 65535, the field is not converted and it is treated as binary data.
- 1-65533
- Specify the CCSID to be used when the CCSID of the from-file field is 65535. If the CCSID of the from-file field is not 65535, this parameter is ignored.
Top |
To CCSID (TOCCSID)
Specifies the coded character set identifier (CCSID) to use for the file specified for the To data base file (TOFILE) parameter.
- *FILE
- The CCSID of the to-file database file is used.
- 1-65533
- Specify the CCSID to be used when the CCSID of the to-file is 65535. If the to-file CCSID is not 65535, an error message will be sent.
Top |
Stream file CCSID (STMFCCSID)
Specifies the method of obtaining the stream file coded character set identifier (CCSID) equivalent of the code page that is used for data conversion.
This parameter can not be specified with the Stream file code page (STMFCODPAG) parameter.
- *STMF
- If the stream file exists, and data conversion is requested, the CCSID equivalent of the code page associated with the stream file is used to perform the conversion.
If the stream file does not exist, the CCSID equivalent of the source database file CCSID is used and associated with the stream file.
- *STDASCII
- If the stream file exists, this option is valid only if the CCSID equivalent of the code page associated with the stream file is the same as the specified value. Otherwise, the operation will fail.
If the stream file does not exist, a CCSID in the IBM PC Data encoding scheme (x2100) is computed. This CCSID is associated with the target stream file and is used for data conversion if it is requested.
- *PCASCII
- If the stream file exists, this option is valid only if the CCSID equivalent of the code page associated with the stream file is the same as the specified value. Otherwise, the operation will fail.
If the stream file does not exist, a CCSID in the Microsoft Windows encoding scheme (x4105) is computed. (Microsoft and Windows are registered trademarks of Microsoft Corporation). This CCSID is associated with the target stream file and is used for data conversion if it is requested. This option allows the resulting data to be used by Microsoft Windows applications.
- 1-65533
- Specify the desired CCSID of the stream file. If the stream file exists, this option is valid only when the specified value matches the CCSID of the stream file. Otherwise, an error message is sent. If the stream file does not exist, the specified CCSID is associated with the stream file when it is created.
Top |
Stream file code page (STMFCODPAG)
Specifies the method of obtaining the stream file code page and the coded character set identifier (CCSID) equivalent of the code page that is used for data conversion.
This parameter can not be specified with the Stream file CCSID (STMFCCSID) parameter.
Note: This parameter is replaced by STMFCCSID but the STMFCODPAG parameter can still be used. However, because this parameter may be removed in a later release, use the STMFCCSID parameter whenever possible.
- *STMF
- If the stream file exists, and data conversion is requested, the CCSID equivalent of the code page associated with the stream file is used to perform the conversion.
If the stream file does not exist, the code page equivalent of the source database file CCSID is used and associated with the stream file.
- *STDASCII
- If the stream file exists, this option is valid only if the code page associated with the stream file is the same as the specified value. Otherwise, the operation will fail.
If the stream file does not exist, a code page in the IBM PC Data encoding scheme (x2100) is computed. This code page is associated with the target stream file and is used for data conversion if it is requested.
- *PCASCII
- If the stream file exists, this option is valid only if the code page associated with the stream file is the same as the specified value. Otherwise, the operation will fail.
If the stream file does not exist, a code page in the Microsoft Windows encoding scheme (x4105) is computed. (Microsoft and Windows are registered trademarks of Microsoft Corporation). This code page is associated with the target stream file and is used for data conversion if it is requested. This option allows the resulting data to be used by Microsoft Windows applications.
- 1-32767
- Specify the codepage to be used. If the stream file exists, this option is only valid if the code page associated with the stream file is the same as the specified value. Otherwise, an error message is sent. If the stream file does not exist, the specified code page is associated with the stream file when it is created.
Top |
Stream file authority (STMFAUT)
Specifies the method of assigning authority settings to the specified output stream file to which data is to be copied. If the specified output stream file already exists, this parameter is ignored.
- *DFT
- The owner of stream file will be granted *RWX data authority to the stream file. The primary group and *PUBLIC will have *NONE data authority to the stream file. Object authorities will be based on the object authorities for the directory where the stream file is to be created.
- *INDIR
- The authority settings of the output stream file are based on the authority for the directory where the stream file is to be created. The stream file is assigned the same public authority, private authorities, primary group, primary group authority, authorization list, and auditing value as the directory in which it is created. If the target file system does not support the *INDIR special value, the command will fail.
- *FILE
- The authority settings of the output stream file are based on the authority for the object specified on the From file (FROMFILE) parameter. The stream file is assigned the same public authority, private authorities, primary group, primary group authority, authorization list, and auditing value as the from-file object being copied. If the target file system does not support one or more of these values, the unsupported values will be ignored.
If the from-file object is a multi-system file, the default value *DFT is used instead of the *FILE value.
- *INDIRFILE
- The resulting authority information will be similar to that produced by copying and pasting a stream file using IBM System i Navigator graphical user interface. The authority information for the stream file will initially be based on the directory where the stream file is created. Then, authority information from the object specified on the From file (FROMFILE) parameter will be copied to the object. This may replace some of the initial authority information obtained from the directory.
If the from-file object is a multi-system file, the default value *INDIR is used instead of the *INDIRFILE value.
Top |
Record delimiter (RCDDLM)
Specifies the record delimiter of the to-file.
If the TOFILE parameter is specified, valid values are *EOR or a character value. If the TOSTMF parameter is specified, valid values are *CR, *CRLF, *LF, *LFCR or *ALL.
- *EOR
- End of record.
- *CRLF
- Carriage-return followed by line-feed is appended to the end of the line.
- *LF
- Line-feed is appended to the end of the line.
- *CR
- Carriage-return is appended to the end of the line.
- *LFCR
- Line-feed followed by carriage-return is appended to the end of the line.
- character-value
- Specify the single character which indicates the end of a single record.
Top |
Record format of import file (DTAFMT)
Specifies the format of the data of the generated to-file.
- *DLM
- The data contains delimiter characters. Refer to parameter descriptions for STRDLM, FLDDLM, and RCDDLM for information on string, field, and record delimiter characters.
- *FIXED
- The data format is fixed. The data is in fixed columns in each record. Refer to the Null field indicator (NULLIND) parameter for more information on how null fields will appear in the to-file. The fixed length is determined by the maximum number of characters the field will need to represent the field and this may result in extra characters returned to pad the maximum length.
Top |
String delimiter (STRDLM)
Specifies the string delimiter for the data of the fields being copied to. This character indicates the start and end of character, date, time, and timestamp strings in the to-file. Depending on the utility used to create the to-file, some types of strings may appear in the to-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 to-file. If the to-file CCSID is 1200, 1208, or 13488 the delimiter is converted to the job CCSID, or to the job's default CCSID when the job CCSID is 65535.
- *DBLQUOTE
- The double quote character is used as the string delimiter.
- *NONE
- No delimiter is expected as the string delimiter. The blank character ( ) represents the *NONE value.
- character-value
- Specify the character value for the string delimiter.
Top |
String escape character (STRESCCHR)
Specifies the escape character to be generated within string fields in the to-file. Character fields in the to-file may contain characters that have a special meaning to the import utility. These characters include the string delimiter and the string escape character itself.
The string escape character precedes such characters in the to-file data and revokes their special meaning. The import utility can then determine if the character is data or a 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 to-file. If the to-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.
- *STRDLM
- The string delimiter is used as the escape character. Each string delimiter in a from-file character field is exported as two adjacent string delimiters.
- *NONE
- No string escape character is inserted in the data. If the string delimiter character is present in the data, unexpected results could occur in the import utility that relies on the to-file.
- character-value
- Specify the character to be used as the escape character.
Top |
Remove blanks (RMVBLANK)
Specifies whether blanks are removed or retained. This parameter is ignored when the DTAFMT parameter is set to *FIXED unless the *EOR value is used.
- *NONE
- All leading and trailing blanks are retained.
- *LEADING
- Leading blanks are removed.
- *TRAILING
- Trailing blanks are removed.
- *BOTH
- Leading and trailing blanks are removed.
- *EOR
- Trailing blanks are removed from the last field of the record.
Top |
Field delimiter (FLDDLM)
Specifies the field delimiter for the record. This value is placed between fields.
- ','
- A comma is used as the field delimiter.
- *TAB
- The horizontal tab character is used as field delimiter.
- character-value
- Specify the character value for the field delimiter.
Top |
Null field indicator (NULLIND)
Specifies whether the first character following each field will contain either a Y or N indicating if the field is null. NULLIND(*YES) is only valid if *FIXED is specified for the Record format of import file (DTAFMT) parameter.
- *NO
- Do not add the null value indicator character after each field.
- *YES
- Add the null value indicator character after each field in the generated fixed-format to-file.
Top |
Numeric field pad (NUMFLDPAD)
Specifies the padding applied for numeric fields. This parameter is ignored when the DTAFMT parameter is not *FIXED.
- *NONE
- No padding, resulting in left justification.
- *BLANK
- Left padding with blanks, resulting in right justification.
- *ZERO
- Left padding with zeroes.
Top |
Decimal point (DECPNT)
Specifies the decimal point character to be used when copying numeric data to the to-file.
- *PERIOD
- A period (.) is used for the decimal point character.
- *COMMA
- A comma (,) is used for the decimal point character.
Top |
Date format (DATFMT)
Specifies the date format to be used when copying date fields to the to-file.
- *ISO
- The International Organization for Standardization (ISO) date format yyyy-mm-dd is used.
- *USA
- The United States date format mm/dd/yyyy is used.
- *EUR
- The European date format dd.mm.yyyy is used.
- *JIS
- The Japanese Industrial Standard date format yyyy-mm-dd is used.
- *YYMD
- The date format yyyymmdd is used.
Top |
Time format (TIMFMT)
Specifies the time format to be used when copying time fields to the to-file.
- *ISO
- The International Organization for Standardization (ISO) time format hh.mm.ss is used.
- *USA
- The United States time format hh:mm xx is used, where xx is AM or PM.
- *EUR
- The European time format hh.mm.ss is used.
- *JIS
- The Japanese Industrial Standard time format hh:mm:ss is used.
Top |
Order by (ORDERBY)
Specifies the order of the records that the records will be inserted in the to file.
- *NONE
- No specific order requested.
- *ARRIVAL
- The records will be inserted in the order they were inserted into the from file.
- character-value
- Specify an SQL ORDER BY clause that will be used for ordering the records in the to file.
Top |
Add column names (ADDCOLNAM)
Specifies if the column names should be added to the first record of the to file.
- *NONE
- No column names will be added.
- *SQL
- The SQL column names will be added.
- *SYS
- The system column names will be added.
Top |
Examples
CPYTOIMPF FROMFILE(DB2FILE) TOFILE(EXPFILE) FLDDLM(';') RCDDLM(X'07') STRDLM(*DBLQUOTE) DATFMT(*JIS) TIMFMT(*JIS)
All records of externally described file DB2FILE will be copied to import file EXPFILE. Fields in the import file will be delimited by semi-colon (;) characters. Each record in the import file will be delimited by a hexadecimal '07' character. Character, date, time, and timestamp values will begin and end with the double quote character. Date and time fields will be in the *JIS format.
Top |
Top |