Using SEARCH without setting INDEX in COBOL.
Using SEARCH without setting INDEX in COBOL.
Hi,
What happens if we donot set the index before search, will this work?
What happens if we donot set the index before search, will this work?
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Using SEARCH without setting INDEX in COBOL.
It depends on what you are trying to do. Have you looked at the documentation, it should be clear what will happen.
-
- Global Moderator
- Posts: 588
- Joined: Wed Nov 20, 2013 11:53 am
- Location: Mars
Re: Using SEARCH without setting INDEX in COBOL.
Also suggest to try it yourself if you have access to Mainframes.
zprogrammer
Re: Using SEARCH without setting INDEX in COBOL.
I came to know that for SEARCH to work in COBOL defining INDEX is mendatory but I could not test it, as I don't have the mainframe access yet.
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Using SEARCH without setting INDEX in COBOL.
You could try to install GNU COBOL (formerly OpenCOBOL) to try things out.
It is unclear what you mean exactly by "definiing INDEX is mandatory". SEARCH does no definitions at all.
It is unclear what you mean exactly by "definiing INDEX is mandatory". SEARCH does no definitions at all.
Re: Using SEARCH without setting INDEX in COBOL.
I wrote a post but i am not able to see it now...
If want the table to be in specific order then the INDEX needs be defined..right?
If want the table to be in specific order then the INDEX needs be defined..right?
- Anuj Dhawan
- Founder
- Posts: 2806
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: Using SEARCH without setting INDEX in COBOL.
Did you click on the Submit button or just complied a reply? I doubt it was the later case!Ramnath wrote:I wrote a post but i am not able to see it now...
Thanks,
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Using SEARCH without setting INDEX in COBOL.
There is no necessary relationship between the order of data and whether an INDEX is defined.
- Robert Sample
- Global Moderator
- Posts: 1897
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Using SEARCH without setting INDEX in COBOL.
A COBOL table, unlike a VSAM KSDS, does not order the data in the table by the index. Data in a COBOL table is in the order your program loads it. Whether or not an INDEX is defined in the DATA DIVISION has nothing to do with the order of the data.If want the table to be in specific order then the INDEX needs be defined..right?
- Anuj Dhawan
- Founder
- Posts: 2806
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: Using SEARCH without setting INDEX in COBOL.
Hello Ramnath
The thread seems to go nowhere - are you, by chance, talking about SEARCH ALL and the table declaration with INDEX and KEY ASCENDING/DESCENDING?
The thread seems to go nowhere - are you, by chance, talking about SEARCH ALL and the table declaration with INDEX and KEY ASCENDING/DESCENDING?
Thanks,
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
- Robert Sample
- Global Moderator
- Posts: 1897
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Using SEARCH without setting INDEX in COBOL.
No, you have not. COBOL has the SEARCH verb, which does a sequential search of a table, as well as SEARCH ALL, which does a binary search of a table. The binary SEARCH will fail if the data in the table is not sorted by the index whereas a sequential SEARCH can succeed no matter whether the data is sorted or not. You asked about SEARCH without specifying whether or not you are doing a binary search -- and the SEARCH works very differently compared to SEARCH ALL. If you read the Enterprise COBOL Language Reference manual, you will find that a sequential SEARCH uses an index but that index does not have to be defined on the table you are searching.Yes, I have askedthe same??
Re: Using SEARCH without setting INDEX in COBOL.
I re-read my posts and understand that how less I was making sense in getting the answer. Thanks for your all help, it really heped me to understand about SEARCH and SEARCH ALL.
- Anuj Dhawan
- Founder
- Posts: 2806
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: Using SEARCH without setting INDEX in COBOL.
That's great and thanks for the feedback. Nothing to worry, as you progress in your career you'll learn to explain better yourself.
Thanks,
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute