Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Multiple ' ASCENDING KEY IS '

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Wed Mar 11, 2009 4:14 pm    Post subject: Multiple ' ASCENDING KEY IS '
Reply with quote

hello,

I searched the forum but could not find any satisfactory answer.

I know we can give multiple keys in Ascending keys clause in a table.

Like

ASCENDING KEY IS Key1 Key2

The question is :

1. What exactly happens to the table ? Does it gets sorted on two keys individually ? or first it sorts it on Key1 and then on Key2

2. In my program I am adding a new key to the ASCENDING clause. Will that affect my existing searchs ?

Please advise.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8165
Location: East Dubuque, Illinois, USA

PostPosted: Wed Mar 11, 2009 4:48 pm    Post subject:
Reply with quote

The manuals link at the top of the page contains the COBOL Language Reference manual, which says in section 5.3.11.2 on ASCENDING KEY:
Quote:
The following example illustrates the specification of ASCENDING KEY data items:


Code:
     WORKING-STORAGE SECTION.
     01  TABLE-RECORD.
         05  EMPLOYEE-TABLE OCCURS 100 TIMES
             ASCENDING KEY IS WAGE-RATE EMPLOYEE-NO
             INDEXED BY A, B.
           10  EMPLOYEE-NAME                     PIC X(20).
           10  EMPLOYEE-NO                       PIC 9(6).
           10  WAGE-RATE                         PIC 9999V99.
           10  WEEK-RECORD OCCURS 52 TIMES
               ASCENDING KEY IS WEEK-NO INDEXED BY C.
             15  WEEK-NO                         PIC 99.
             15  AUTHORIZED-ABSENCES             PIC  9.
             15  UNAUTHORIZED-ABSENCES           PIC  9.
             15  LATE-ARRIVALS                   PIC  9.


The keys for EMPLOYEE-TABLE are subordinate to that entry, and the key for WEEK-RECORD is subordinate to that subordinate entry.

In the preceding example, records in EMPLOYEE-TABLE must be arranged in ascending order of WAGE-RATE, and in ascending order of EMPLOYEE-NO within WAGE-RATE. Records in WEEK-RECORD must be arranged in ascending order of WEEK-NO. If they are not, results of any SEARCH ALL statement are unpredictable.
So the answer to your first question is, no the table must be sorted before loading -- by you -- and must be sorted by secondary key within primary key. The answer to your second question is of course existing searches will be affected if you add another key.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts ejck thru rexx to multiple jobs insid... Susanta All Other Mainframe Topics 5 Tue Sep 19, 2017 1:39 pm
No new posts PLI - printing from multiple programs Pedro PL/I & Assembler 8 Fri Sep 08, 2017 6:36 am
No new posts Repeat part of record multiple times Learncoholic DFSORT/ICETOOL 4 Tue Aug 29, 2017 11:33 am
No new posts Match two files using multiple keys a... santoshks1987 SYNCSORT 11 Fri Aug 18, 2017 10:50 am
No new posts Multiple VSAM files single output fil... Mohan Kothakota DFSORT/ICETOOL 11 Wed Aug 09, 2017 7:57 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us