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
 

 

Position of index when sequential search in not

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

New User


Joined: 29 Sep 2008
Posts: 6
Location: United Kingdom

PostPosted: Tue Dec 29, 2009 11:49 am    Post subject: Position of index when sequential search in not
Reply with quote

Hi,
I have a query related to sequential search in COBOL.
What would be the position on index when a sequential search is not successful.
Is it the last position ?
n+1 where n is the last position where data in stored in a table
or n.
Ex - A table with OCCURS 10 INDEXED BY I.
Suppose there is data in 5 positions.
If search is not successful the position of index is 10,6,5. I read somewhere that it is unpredictable.
Please help.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


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

PostPosted: Tue Dec 29, 2009 4:31 pm    Post subject:
Reply with quote

The COBOL Language Reference (manuals link at the top of the page), section 6.2.32.1 on sequential SEARCH, is quite clear:
Quote:
If the end of the table is reached (that is, the value of the incremented index is greater than the highest possible occurrence number) without the WHEN condition being satisfied, the search is terminated.
In other words, the value will be 11 for your example.

Please note that the actual number of elements you've loaded into the table has no bearing upon the SEARCH verb. Only the defined number of elements (10 in your example) matters -- the fact that you've loaded only 5 elements means that you're comparing unknown values for the last 5 search tests (possibly LOW-VALUES, possibly something else).

If a BINARY search fails, the index value will be unpredictable. However, if a SEQUENTIAL search fails the index value is known.
Back to top
View user's profile Send private message
peyush

New User


Joined: 29 Sep 2008
Posts: 6
Location: United Kingdom

PostPosted: Tue Dec 29, 2009 5:41 pm    Post subject:
Reply with quote

Thanks for the response.
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 SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts To find out size allocated to a seque... ashek15 JCL & VSAM 15 Thu Apr 27, 2017 9:42 am
No new posts setting new limit Key values for inde... srilata83 DB2 1 Fri Feb 10, 2017 9:24 pm
No new posts Order BY AND Index Nileshkul DB2 2 Sat Dec 31, 2016 6:33 pm


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