Random Access for a KSDS file



Help for IBM's record-oriented filesystem VSAM, ESDS, KSDS, RRDS, LDS and Storage management Subsystems

Random Access for a KSDS file

Postby ashwin1990 » Wed Mar 07, 2012 11:28 am

while accessing a KSDS file using random access method, do we have to re initialize the pointer back to the starting position evrytime if i am accessing more than 1 record.
ashwin1990
 
Posts: 32
Joined: Mon Feb 27, 2012 4:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Random Access for a KSDS file

Postby BillyBoyo » Wed Mar 07, 2012 12:53 pm

I'm going to guess "no", because I can't think of anything like that using VSAM from Cobol.

However, it is a guess because I don't really know what you are talking about.

Try not doing anything except READing. If that doesn't work for you, post your code, SELECT, FD and I/O statements, please.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Random Access for a KSDS file

Postby mongan » Wed Mar 07, 2012 1:48 pm

I think your terminology is not correct. Are you talking about a read using a key, or are you talking about a start and read next scenario?
User avatar
mongan
 
Posts: 211
Joined: Tue Jan 11, 2011 8:32 pm
Has thanked: 1 time
Been thanked: 5 times

Re: Random Access for a KSDS file

Postby Robert Sample » Wed Mar 07, 2012 5:37 pm

As has been mentioned, it is difficult to tell what you are asking since your terminology is so vague.

However, since you do not have to initialize any pointer to do a random read of a KSDS file (you merely have to ensure the key contains the value you want), I'm guessing the answer is probably not.

On the other hand, if you're thinking of dynamic processing (where you randomly read a record, then use sequential processing to read the next record(s)), then you would not want to change the key since that would affect your sequential processing.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Random Access for a KSDS file

Postby ashwin1990 » Sun Mar 11, 2012 5:58 pm

my question was that suppose i am reading a record (eg 10th record) from a KSDS file using random access method for the first time. now the second time i want to read 5th record. So in this case do we have to re initialize the pointer back to the first record again???
ashwin1990
 
Posts: 32
Joined: Mon Feb 27, 2012 4:44 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Random Access for a KSDS file

Postby Robert Sample » Sun Mar 11, 2012 6:09 pm

It is STILL not clear what you want to know. Since you do NOT have to initialize anything to read a KSDS randomly, why would you think you do? On the other hand, if what you are doing is working then why are you posting on this forum? And if you are talking about a KSDS, why are you using terms like "10th record" and "5th record" since a KSDS is read by key value not record number -- terms that are used with RRDS files in VSAM?

If what you are doing is working, then go with it -- even if it is not the most efficient way, at least it is working. If what you are doing is not working, you're going to need to post the LISTCAT for the file (so we can see if you want KSDS or RRDS), as well as the code you are using to read the file, in order for us to help you.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Random Access for a KSDS file

Postby BillyBoyo » Sun Mar 11, 2012 6:51 pm

You are talking about a VSAM KSDS on a Mainframe, we assume. We also assume you are using Cobol.

You establish a file a being a KSDS with RANDOM access.

You open the file.

You populate a key field and issue a READ for that key. You can tell that you were able to read with that key, or that you weren't.

You cannot tell which record, as far as relative sequence in the file, you read.

To read another record with a lower key, all you need to do is set up the key and issue the read. Same for a record with a higher key.

There is nothing you can set or reset relating to the KSDS (or any VSAM file).

This is why we cannot make good sense of your question.

Although you can do RANDOM access with keys in any order, where possible you should do it in key order, as the program will run better (there will be no occasion where a buffer is filled, discarded because of a lower key, and then the same data is again accessed later, so ends up being physically read again).
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Random Access for a KSDS file

Postby ashwin1990 » Mon Mar 12, 2012 9:18 pm

thnks guys for ur help............. really appreciate it........
ashwin1990
 
Posts: 32
Joined: Mon Feb 27, 2012 4:44 pm
Has thanked: 0 time
Been thanked: 0 time


Return to VSAM/SMS

 


  • Related topics
    Replies
    Views
    Last post