Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 8119
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 Changeman get multiple "Browse C... elixir1986 Compuware & Other Tools 4 Fri Jul 14, 2017 1:48 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
This topic is locked: you cannot edit posts or make replies. SDSF multiple spool datasets extracte... PJAlarcon CLIST & REXX 1 Fri Apr 21, 2017 10:50 pm
No new posts Validating file with multiple header/... mohitsaini DFSORT/ICETOOL 6 Thu Apr 13, 2017 1:53 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us