File Management - IBM

File Management - IBM File Management - IBM

as400bks.rochester.ibm.com
from as400bks.rochester.ibm.com More from this publisher
30.06.2013 Views

| | | | | | | | | | | | | | | | | | | | object. This is true unless the user is a member of a group profile and has OWNER(*GRPPRF) specified for the profile. If you specify OWNER(*GRPPRF), the group profile becomes the owner of the to-file. In this case, if the user profile running the copy command does not have authority to add a member or write data to the new file, the copy command fails. The created to-file does not maintain the file capabilities of the from-file. The to-file allows update, delete, read, and write operations, regardless of whether the from-file allowed these operations. Following are special considerations for the new to-file: v If the number of records copied into a member is greater than the maximum size of the created to-file, the to-file is extended without intervention by the system operator. v If the from-file is an SQL table, view, or index, the created to-file will be a physical file that is not an SQL table. However, when the from-file contains LOBs, datalinks, or user-defined types, the created to-file is an SQL table. v If the from-file has a trigger program associated with it, the CPYF and CPYFRMQRYF commands do not copy the trigger information to the to-file when the CRTFILE parameter is used. v If you create a new file (CRTFILE(*YES)) from a file with constraints, the constraint definitions do not copy to the new file. v If you create a new file (CRTFILE(*YES)) from a file with user-defined functions, the user-defined functions do not copy to the new file. Adding, replacing, and updating records (MBROPT parameter) 84 File Management V4R5 On the CPYF, CPYFRMDKT, CPYFRMQRYF, CPYFRMTAP, or CPYSRCF commands, you can add or replace existing data in the to-file by specifying different attributes on the MBROPT parameter. The CPYF command also allows you to update duplicate key records and add non-duplicate key records to a to-file member. You can do these tasks by specifying *REPLACE, specifying *ADD, or specifying *UPDATE on the MBROPT parameter (see page Specifying *REPLACE when copying files). Specifying *REPLACE when copying files By specifying *REPLACE, you essentially clear the member. The copied records are the only records in the member when the operation completes. You must have authority to clear the member in order to specify MBROPT(*REPLACE). For copy commands other than the CPYFRMQRYF command, when you specify *REPLACE, copy command processing fails if the from-file does not contain any records. When you specify *REPLACE on the CPYFRMQRYF command, the to-file member will be cleared even if the open query file contains no records. *REPLACE is the default value for the CPYSRCF command. All other copy commands have the default value of *NONE; however, *NONE is valid only for copying to a device file.

| | | | | | | | | | | | Relative Record Number 1 2 3 4 1 2 3 4 5 6 7 1 2 3 Specifying *ADD when copying files File A ....... ........ ....... .... File B ......... ........ ....... ....... ....... ..... ...... File C ...... ........ ........ When you specify *ADD, each record copied is added to the end of the existing records in the member. It is important to note that this is always true, even for keyed files. However, with keyed files, the added records appear to be merged in key sequence when accessed through a keyed access path. When copying from query files, the relative record numbers of the resulting file may not correspond to those in the original file. When *ADD is specified, the copy completes normally even if the from-file contains no records. When three files are copied with MBROPT(*ADD) to a database file that is not keyed, the resulting to-file would look like Figure 13. Relative Record Number 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Figure 13. Result of Copies with MBROPT(*ADD) Specified To-File Member File A File B File C RV2H078-0 Chapter 4. Copying files 85

|<br />

|<br />

|<br />

|<br />

|<br />

|<br />

|<br />

|<br />

|<br />

|<br />

|<br />

|<br />

Relative<br />

Record<br />

Number<br />

1<br />

2<br />

3<br />

4<br />

1<br />

2<br />

3<br />

4<br />

5<br />

6<br />

7<br />

1<br />

2<br />

3<br />

Specifying *ADD when copying files<br />

<strong>File</strong> A<br />

.......<br />

........<br />

.......<br />

....<br />

<strong>File</strong> B<br />

.........<br />

........<br />

.......<br />

.......<br />

.......<br />

.....<br />

......<br />

<strong>File</strong> C<br />

......<br />

........<br />

........<br />

When you specify *ADD, each record copied is added to the end of the existing<br />

records in the member. It is important to note that this is always true, even for<br />

keyed files. However, with keyed files, the added records appear to be merged in<br />

key sequence when accessed through a keyed access path. When copying from<br />

query files, the relative record numbers of the resulting file may not correspond to<br />

those in the original file.<br />

When *ADD is specified, the copy completes normally even if the from-file<br />

contains no records.<br />

When three files are copied with MBROPT(*ADD) to a database file that is not<br />

keyed, the resulting to-file would look like Figure 13.<br />

Relative<br />

Record<br />

Number<br />

1<br />

2<br />

3<br />

4<br />

5<br />

6<br />

7<br />

8<br />

9<br />

10<br />

11<br />

12<br />

13<br />

14<br />

Figure 13. Result of Copies with MBROPT(*ADD) Specified<br />

To-<strong>File</strong> Member<br />

<strong>File</strong> A<br />

<strong>File</strong> B<br />

<strong>File</strong> C<br />

RV2H078-0<br />

Chapter 4. Copying files 85

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!