How to read a KSDS file using part of its key?



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

How to read a KSDS file using part of its key?

Postby ashwin1990 » Mon Jun 18, 2012 12:08 pm

Hi All,

I want to read a KSDS file using part of its key.

eg: Suppose my KSDS file has a key of lenth 20, i want to read it using key, starting from position 10.

Is it possible to do so????
ashwin1990
 
Posts: 32
Joined: Mon Feb 27, 2012 4:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to read a KSDS file using part of its key?

Postby mongan » Mon Jun 18, 2012 1:14 pm

No, you will need to use an alternate index.
User avatar
mongan
 
Posts: 211
Joined: Tue Jan 11, 2011 8:32 pm
Has thanked: 1 time
Been thanked: 5 times

Re: How to read a KSDS file using part of its key?

Postby ashwin1990 » Mon Jun 18, 2012 2:06 pm

but again alternate index has to start from position 1 ..... isnt it???

I want to read from position 10.
ashwin1990
 
Posts: 32
Joined: Mon Feb 27, 2012 4:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to read a KSDS file using part of its key?

Postby enrico-sorichetti » Mon Jun 18, 2012 2:18 pm

NO!
an alternate index key can start wherever You feel the need to.

but ... processing thru an alternate key might return the records in a different sequence than the primary key.
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: How to read a KSDS file using part of its key?

Postby ashwin1990 » Mon Jun 18, 2012 2:23 pm

ok....... thnks :)
ashwin1990
 
Posts: 32
Joined: Mon Feb 27, 2012 4:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to read a KSDS file using part of its key?

Postby mongan » Mon Jun 18, 2012 5:22 pm

Depending on how large your file is and what you want to do you might be better off extracting the records and sorting them. Don't forget that when you use an alternate key that you my have duplicate keys (same key for different records). Maybe you should share what you are exactly doing or want to do.
User avatar
mongan
 
Posts: 211
Joined: Tue Jan 11, 2011 8:32 pm
Has thanked: 1 time
Been thanked: 5 times

Re: How to read a KSDS file using part of its key?

Postby dick scherrer » Mon Jun 18, 2012 7:59 pm

Hello,

I suspect the "key" is made up of multiple fields and the requirement is to select records based on something that that is NOT the high-order part of the key.

To do this directly, an alternate key of just what IS needed could be defined.

This will imply extra overhead as well as extra space that would need to be weighed against how often this "query" would be executed and how much data is in the file.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post