Merge. DORIC 9.65, INFO-Text software
Quảng cáo
Quảng cáo
MERGE
MERG
E syntax cont’d
[
I
NTO DF_name] [ON] DF_item_1 [(
D
)]
[,DF_name_2...] [
U
NSORTED]
merges a selected set of records from one data file either into the unselected set of records from the same data file or into another data file. The values of up to 16 data file items common to both sets of records may be used to control the merge.
arguments notes
[INTO DF_name] is used when you want to merge the selected set of records into another data file.
[ON] is used only for documentation and clarification.
DF_item_1 is the item used as the primary merge key.
[(D)] tells INFO to merge the records in descending order by the named item. You must enclose the D in parentheses. If you do not use the D option, INFO merges the records in ascending order.
[,DF_name_2...] item or items used as secondary merge keys.
[UNSORTED] tells INFO that the selected records are not sorted. If this is the case, INFO sorts the selected records by the specified key items before processing the merge.
n
For more efficient processing, always merge a smaller set of records into a larger set of records or a smaller file into a larger file.
n
It is not possible to merge records into an ISAM file.
INFO Reference Manual Commands 341
MERGE discussion
PRIME
Use the MERGE command when you want to add or update records in a file in sorted order without having to resort the entire file.
You can merge unselected records from one file into the unselected records of the same file or into another file. In either case, merge the records on specified items. You can specify up to 16 items. The first item you specify is the primary merge key. Any other items you specify are secondary merge keys and are processed in the order specified.
If you merge records from one data file into another data file, the data files must have the same format and record length.
Both sets of records, whether they are from the same data file or not, should be sorted by the items you specify. If the selected set of records is not sorted, use the
UNSORTED option and INFO sorts it. If you do not sort the records and you do not use the UNSORTED option,
INFO displays an error message and aborts the merge.
For example, if you merge the data file D.NEW.EMPS into the data file D.MASTER on the items BRANCH and
DEPT, in that order, and both files are sorted on those items, the selected records from D.NEW.EMPS will be put into D.MASTER in sorted order, first according to the value of BRANCH and then within BRANCH according to the value of DEPT.
If a selected record has the same value for the specified merge item(s) as a record in the destination set of records,
INFO puts the selected record after the destination record in the file.
The existing file protection status is maintained after
MERGE, rather than set to the value held within
$RWLOCK.
342 Commands INFO Reference Manual
MERGE examples
To update records in a sorted file without having to resort the file:
ENTER COMMAND >SELECT D.MASTER
7 RECORD(S) SELECTED
ENTER COMMAND >LIST
$RECNO BRANCH DEPT NAME
1 1 100 KITTY
2 1 200 LISA
3 1 200 MIRIAM
4 2 100 PAUL
5 2 200 TRISH
6 2 200 SHARON
7 2 300 STEVE
The file is sorted on BRANCH and on
DEPT within BRANCH.
ENTER COMMAND >RESELECT FOR BRANCH = 2 AND DEPT = 200
2 RECORD(S) SELECTED
ENTER COMMAND >CALCULATE DEPT = 50
ENTER COMMAND >LIST
$RECNO BRANCH DEPT NAME
5 2 50 TRISH
6 2 50 SHARON
ENTER COMMAND >MERGE ON BRANCH,DEPT
ENTER COMMAND >ASELECT
7 RECORD(S) SELECTED
ENTER COMMAND >LIST
$RECNO BRANCH DEPT NAME
1 1 100 KITTY
2 1 200 LISA
3 1 200 MIRIAM
4 2 50 TRISH
5 2 50 SHARON
6 2 100 PAUL
7 2 300 STEVE
INFO Reference Manual Commands 343
MERGE
Or to add records in sorted order from one file to another file:
ENTER COMMAND >SELECT D.NEW.EMPS
3 RECORD(S) SELECTED
ENTER COMMAND >LIST
$RECNO BRANCH DEPT NAME
1 2 100 PAULA
2 1 200 JOE
3 2 150 DOM
ENTER COMMAND >MERGE INTO D.MASTER ON BRANCH,DEPT U
The U or UNSORTED option sorts the selected file before processing the merge.
ENTER COMMAND >SELECT D.MASTER
10 RECORD(S) SELECTED
ENTER COMMAND >LIST
$RECNO BRANCH DEPT NAME
1 1 100 PAULA
2 1 200 JOE
3 1 200 DOM
4 1 200 PAULA
5 2 50 JOE
6 2 50 DOM
7 2 100 PAUL
8 2 100 PAULA
9 2 150 DOM
10 2 300 STEVE
344 Commands INFO Reference Manual
Tải xuống
Quảng cáo