Page 1 of 1

Can we do partial key generic read in a VSAM file?

Posted: Thu Oct 30, 2014 11:54 am
by Arun Mani
Hi,

For one of the requirements I'm supposed to read a VSAM file with a partial key only. Can you please give me some pointers about this as I'm not sure if can do this.

Thanks and Regards,

Re: Can we do partial key generic read in a VSAM file?

Posted: Thu Oct 30, 2014 6:21 pm
by Robert Sample
Your post is very lacking in details -- such as which language you want to use and where the partial key you wan to use starts. As long as the partial key you want to use consists of the start of the key, what you want to do is possible. If you want to read a partial key that does not start with the first byte of the key, then what you want to do is not possible.

With COBOL, you would issue a

Code: Select all

START <file name> KEY IS NOT LESS THAN <variable name> 
command on the partial key and then do a READ NEXT to retrieve the first record. Depending upon the specifics of the key, it may be possible to use spaces for the part of the key you do not have a value for, or you may need to have LOW-VALUES in that part of the key.

Re: Can we do partial key generic read in a VSAM file?

Posted: Fri Nov 21, 2014 4:43 pm
by Arun Mani
Thanks Robert.

I'm might sound badly wrong but for partial key is there some restriction of knowing "left" or "right" part of the key? I'm trying to search on it and I think I got the idea from a discussion with friend but I've confused so badly that my google searches did not really return me somehitng on these lines... :?

Re: Can we do partial key generic read in a VSAM file?

Posted: Fri Nov 21, 2014 6:21 pm
by Robert Sample
A generic key read MUST start with the first byte of the key (the leftmost byte if you want) and contains some number of bytes of the key (at most, however, 1 byte less than the length of the key). If you want to do a generic key read of the 7th through 15th bytes of the key, for example, that is not possible since it does not start with the leftmost (first) byte of the key. It would be possible to do a read by defining an alternate index on those bytes and using the alternate index for the read -- but that is not a generic key read and not what was asked.

Re: Can we do partial key generic read in a VSAM file?

Posted: Mon Dec 01, 2014 4:35 pm
by Arun Mani
Thanks Robert. This is useful information.

So if we've a partial key and it does not start from left most byte, we would use AIX, is this a correct learning?

Re: Can we do partial key generic read in a VSAM file?

Posted: Tue Dec 02, 2014 4:11 am
by Robert Sample
Yes, the only way to do this would be to define an alternate index on the part of the key you want to read, then use the alternate index instead of the primary key. Depending upon the precise circumstances, the alternate index may have to allow for duplicate keys -- primary keys have to be unique but partial keys do not.