Download presentation
Presentation is loading. Please wait.
1
THE SORT STATEMENT for files (chp. 14)
Purpose: Syntax Definition: Examples: For Your Information retype! SortMerge
2
THE SORT STATEMENT for files cont (chp. 14)
For Your Information USING PROCEDURES Input procedures are executed prior to the sorting of the file. If you don’t need to process the input records before they are sorted, you can code the USING clause instead. Output procedures are executed following the sorting of the file. Use the GIVING clause if you don’t need to process the sorted records in any way. The Release statement passes a record to the sort work area so it’s ready for sorting (FROM used like on WRITE!) The Return statement makes the next sorted record available to the program (INTO used like on READ!). AT END is executed when there aren’t any more records in the sort work file. Purpose: Syntax Definition: RELEASE sort-work-record-name [ FROM data-name ] RETURN sort/merge-file-name RECORD [ INTO data-name] [ AT END imperative-statement-1 ] [ NOT AT END imperative-statement-2 ] [ END-RETURN ] Examples: See handout SortMerge
3
THE MERGE STATEMENT for files (chp. 14)
Purpose: to arrange the records in a file in a specific order Syntax Definition: MERGE merge-work-file-name { ON { ASCENDING | DESCENDING} KEY {data-name} … } … [ COLLATING SEQUENCE IS alphabet-name] USING file-name-1 {file-name-2} … {OUTPUT PROCEDURE IS proc-name-1 | GIVING {file-name-2} … } Examples: MERGE MERGEWORK ASCENDING ST-LAST-NAME ST-FIRST-NAME SEQUENCE EBCDIC USING FR-FILE SO-FILE JR-FILE SR-FILE GIVING UNDER-GRAD-FILE For Your Information Same as sort, EXCEPT: No input procedure SortMerge
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.