File Management - IBM
File Management - IBM File Management - IBM
94 File Management V4R5 Selecting records by record keys (FROMKEY and TOKEY Parameters) Note: You can use this parameter on the CPYF command only. You can specify record keys to copy only from a keyed database file. You can copy records: v From a specified key value (FROMKEY parameter) to a specified key value (TOKEY parameter) OR v Until a specified number of records (NBRRCDS parameter) is reached (see “Selecting a specified number of records (NBRRCDS Parameter)” on page 98 If the command reaches the end of the file before it reaches the specified ending key value or number of records, the copy completes normally. If no record in the from-file member has a key that is a match with the FROMKEY value, but there is at least one record with a key greater than the specified value, the first record copied is the first record with a key greater than the FROMKEY value. If the specified key value is greater than any record in the member, the command sends an error message and does not copy the member. You can specify *BLDKEY on the FROMKEY and TOKEY parameters to use a list of character and numeric values in their natural display form for the fields in a key. The command converts each element to the corresponding key field data type. The command then provides the composite key value (a key that is comprised of more than one field) to the database. If you specify fewer values than the complete database key contains, the command builds a partial key and passes it to the database. If you specify more values than the database key contains, an ending error occurs. The command always applies values to the consecutive fields that are in the extreme left of the key so that it is impossible to skip key fields. The command pads character fields on the right with blanks. The command adjusts numeric fields to the implied decimal point in the key field with the correct zero padding. All regular rules for specifying numeric fields in an external character format apply. The command does not allow a floating-point value of *NAN (Not a Number). See “Example: build-key function” on page 96 and “Example: using FROMKEY and TOKEY” on page 96 for specific coding examples. It is also important to understand “Key string comparisons made by the copy operation” on page 95 in order to interpret various warning messages. Note: If you use record keys to select records, you cannot use relative record numbers (FROMRCD/TORCD parameters) to select records on the same CPYF command. You should not specify COMPRESS(*NO) when selecting records by record key from a keyed physical file. Because the keyed access path of a file does not contain deleted records, the copy command never copies them, so the compression is automatic.
Because deleted records are canceled in a copy by this method, it is also possible that the relative record numbers have changed in the new file, even if you have specified MBROPT(*REPLACE). See the following topics for more information about specifying data for: v “Variable-length fields used by record keys (FROMKEY and TOKEY)” on page 96 v “Date, time, and timestamp fields used by record keys (FROMKEY and TOKEY)” on page 97 v “Null-capable fields used by record keys (FROMKEY and TOKEY)” on page 97 v “Different CCSIDs used by record keys (FROMKEY and TOKEY)” on page 98 v “DBCS-graphic fields used by record keys (FROMKEY and TOKEY)” on page 98 Key string comparisons made by the copy operation The check made by the copy operation (when the TOKEY value is specified) is a logical character comparison between the key string for each record retrieved and the key string that is: v Specified explicitly (using the first TOKEY parameter format) OR v Built implicitly by the copy operation (that uses the list of values that are given) A warning message is sent (but the copy operation continues) if this comparison gives different results than the ordering in which the database identifies the records in the keyed access path. The order may be different if: v The key contains mixed ascending and descending fields v The key contains fields for which a sort sequence other than *HEX is in effect OR v The key contains any of the following DDS keywords: ABSVAL Absolute value ALTSEQ Alternative collating sequence ALWNULL Allow null DATFMT Date format (*MDY, *DMY, *YMD, *JUL, SAA *EUR, or SAA *USA) DIGIT Digit force SIGNED Signed numeric TIMFMT Time format (*USA) ZONE Zone force If there are both ascending and descending fields in the file key, the first (the far left) key field determines whether the copy operation uses an ascending or descending key test to look for the last record to copy. Using *BLDKEY is the easiest way to specify (and ensure correct padding) values for packed, binary, and floating-point fields. Chapter 4. Copying files 95
- Page 54 and 55: Program A (in user default activati
- Page 56 and 57: 46 File Management V4R5 Override 1
- Page 58 and 59: 48 File Management V4R5 same call l
- Page 60 and 61: 50 File Management V4R5 Program A .
- Page 62 and 63: 52 File Management V4R5 Applying OV
- Page 64 and 65: Deleting overrides 54 File Manageme
- Page 66 and 67: Program A (in user default activati
- Page 68 and 69: 58 File Management V4R5 Displaying
- Page 70 and 71: 60 File Management V4R5 Command 7 d
- Page 72 and 73: 62 File Management V4R5 Display All
- Page 74 and 75: Redirecting files 64 File Managemen
- Page 76 and 77: 66 File Management V4R5 Default act
- Page 78 and 79: 68 File Management V4R5 From Databa
- Page 80 and 81: Copying files: overview 70 File Man
- Page 82 and 83: 72 File Management V4R5 Table 9. Co
- Page 84 and 85: Table 10. Summary of Copy Functions
- Page 86 and 87: 76 File Management V4R5 Copying fil
- Page 88 and 89: Resending copy file completion mess
- Page 90 and 91: 80 File Management V4R5 from-file m
- Page 92 and 93: CPYSRCF command support for CCSIDs
- Page 94 and 95: | | | | | | | | | | | | | | | | | |
- Page 96 and 97: | | | | | | | | | | | | | | | | 86
- Page 98 and 99: | | | | | | | | | | | | | | | | | |
- Page 100 and 101: 90 File Management V4R5 Copying onl
- Page 102 and 103: Selecting the records to copy 92 Fi
- Page 106 and 107: 96 File Management V4R5 Example: bu
- Page 108 and 109: 98 File Management V4R5 When you sp
- Page 110 and 111: 100 File Management V4R5 A field na
- Page 112 and 113: 102 File Management V4R5 v “Null-
- Page 114 and 115: 104 File Management V4R5 - INCCHAR(
- Page 116 and 117: When you specify PRINT(*EXCLD), the
- Page 118 and 119: Note: It is possible for files with
- Page 120 and 121: 110 File Management V4R5 Variable-L
- Page 122 and 123: Table 14 on page 112 outlines the c
- Page 124 and 125: 114 File Management V4R5 in the cur
- Page 126 and 127: 116 File Management V4R5 (including
- Page 128 and 129: | | | | | | | | | | | | | | | | | |
- Page 130 and 131: | | | | | | | | | | | | | | | | | |
- Page 132 and 133: Preventing errors when copying file
- Page 134 and 135: elationship. However, the copy oper
- Page 136 and 137: Preventing allocation errors when c
- Page 138 and 139: 128 File Management V4R5 - A depend
- Page 140 and 141: Year 2000 support: date, time, and
- Page 142 and 143: FLD TYPE DATFMT SPECIFIED FIELD LEN
- Page 144 and 145: Restrictions for Year 2000 support
- Page 146 and 147: | | | | | | | | | | AS/400 supports
- Page 148 and 149: | | | | | | | | | | | | | | | | | |
- Page 150 and 151: Using the Copy From Import File (CP
- Page 152 and 153: externally described database file
Because deleted records are canceled in a copy by this method, it is also possible<br />
that the relative record numbers have changed in the new file, even if you have<br />
specified MBROPT(*REPLACE).<br />
See the following topics for more information about specifying data for:<br />
v “Variable-length fields used by record keys (FROMKEY and TOKEY)” on<br />
page 96<br />
v “Date, time, and timestamp fields used by record keys (FROMKEY and<br />
TOKEY)” on page 97<br />
v “Null-capable fields used by record keys (FROMKEY and TOKEY)” on page 97<br />
v “Different CCSIDs used by record keys (FROMKEY and TOKEY)” on page 98<br />
v “DBCS-graphic fields used by record keys (FROMKEY and TOKEY)” on page 98<br />
Key string comparisons made by the copy operation<br />
The check made by the copy operation (when the TOKEY value is specified) is a<br />
logical character comparison between the key string for each record retrieved and<br />
the key string that is:<br />
v Specified explicitly (using the first TOKEY parameter format) OR<br />
v Built implicitly by the copy operation (that uses the list of values that are given)<br />
A warning message is sent (but the copy operation continues) if this comparison<br />
gives different results than the ordering in which the database identifies the<br />
records in the keyed access path. The order may be different if:<br />
v The key contains mixed ascending and descending fields<br />
v The key contains fields for which a sort sequence other than *HEX is in effect<br />
OR<br />
v The key contains any of the following DDS keywords:<br />
ABSVAL<br />
Absolute value<br />
ALTSEQ<br />
Alternative collating sequence<br />
ALWNULL<br />
Allow null<br />
DATFMT<br />
Date format (*MDY, *DMY, *YMD, *JUL, SAA *EUR, or SAA *USA)<br />
DIGIT<br />
Digit force<br />
SIGNED<br />
Signed numeric<br />
TIMFMT<br />
Time format (*USA)<br />
ZONE Zone force<br />
If there are both ascending and descending fields in the file key, the first (the far<br />
left) key field determines whether the copy operation uses an ascending or<br />
descending key test to look for the last record to copy.<br />
Using *BLDKEY is the easiest way to specify (and ensure correct padding) values<br />
for packed, binary, and floating-point fields.<br />
Chapter 4. Copying files 95