View previous topic :: View next topic
|
Author |
Message |
aakar
New User
Joined: 08 Apr 2008 Posts: 36 Location: mumbai
|
|
|
|
I have a VSAM file indexed on 3 fields and these 3 fields constitute the primary key....If i have values to only 2 of the 3 fields in my code and the third field is unknown then can i access the VSAM using only these two keys....Please the VSAM file below:
Code: |
Primary key Related data
-------+----------- -------------------------------------------------
00000001ABETA ...............................*
00000003BBETA ...............................
00000004BBETA ...............................
00000005CBETA ...............................
00000006CBETA ...............................
00000009ABETA ...............................*
00000011ABETB ...............................
00000013BBETB ...............................
00000014BBETB ...............................
00000015CBETB ...............................
00000016CBETB ...............................
00000019ABETB ............................... |
key1 : first 8 bytes (00000001)
key2 : 9th byte (A/B/C)
key3 : 10th onwards 4 bytes (BETA)
If i have only key2 & key3,
key2 = A
key3 = BETA,combined as ABETA.
Is there any technique wherein i can access all rows in the VSAM using only,
key2 = A
key3 = BETA
that is code should read only the ones i have marked with a star (*) and
it should not read sequentially till it reaches the required record.
Restrictions:
I cannot change primary key, it has to be a combination of the three keys to remain unique.
Nothing else in the data area can be defined as a Alternate index.
I am contemplating the below two approaches:
1. Creating an alternate index out of the primary key
2. Using SHORT KEY method(i.e START with GTEQ option and doing a READ NEXT.) mentioned in this topic:
www.ibmmainframes.com/viewtopic.php?t=34910
(please provide reference on this option.
Sorry for this long post....
Edited: Please use BBcode when You post some code, that's rather readable...Anuj |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Alternate index is probably the better way to go; if you don't know the first part of the key value then you basically have to read the entire file sequentially to find the matches. Reading generic keys with GTEQ only works when you shorten the key from the right, not from the left. |
|
Back to top |
|
|
aakar
New User
Joined: 08 Apr 2008 Posts: 36 Location: mumbai
|
|
|
|
Hi Robert,
Can i then create an AIX such that it consists of key2,key3 even if key2,key3 are a part of primary key. Actually have seen that most programs use AIX's present in the data area. If i define an AIX from the primary key, i shouldn't face any problem accessing it right?
Thanks for the reply..
Can u give some reference link for the GTEQ function, feel that it can be useful to me in some other reference..... |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
As far as your first question, from the manual on defining alternate indexes:
Quote: |
KEYS(length offset]64 0)
describes the alternate-key field in the base cluster's data record.
The key field of an alternate index is called an alternate key. The data record's alternate key can overlap or be contained entirely within another (alternate or prime) key field. |
The manuals link at the top of the page includes the COBOL Language Reference manual, which describes START KEY >= <value>. Usually when I see GTEQ and generic key it is in reference to CICS, and these manuals are also found at the manuals link. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
Back to top |
|
|
aakar
New User
Joined: 08 Apr 2008 Posts: 36 Location: mumbai
|
|
|
|
thanks anuj |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
Back to top |
|
|
aakar
New User
Joined: 08 Apr 2008 Posts: 36 Location: mumbai
|
|
|
|
yeah i did notice that, how was it done, it looks better now. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
aakar wrote: |
how was it done. |
Using BBcode tags.
May be you didn't notice the embedded link in the previous post, hover your mouse on the text "BBcode", it'll be hilighted with a underline, it's a link, click on that. It will tell what is BBcode.
Quote: |
Edited: Please use BBcode when You post some code, that's rather readable...Anuj |
|
|
Back to top |
|
|
aakar
New User
Joined: 08 Apr 2008 Posts: 36 Location: mumbai
|
|
|
|
thanks that will help me make my posts look better..... |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
You're welcome..
-Ad |
|
Back to top |
|
|
aakar
New User
Joined: 08 Apr 2008 Posts: 36 Location: mumbai
|
|
|
|
Hey anuj,
In the same file above, Can we give a short key like this, in the start command,
key1= Low values (or first position)
key2 = A
key3 = BETA
and perform READ-NEXT command. Will this ensure that only the records with these two keys get read and that other records are skipped. so only,
00000001ABETA ......
00000009ABETA ......
gets read. It becomes a performance problem if i do sequential reads searching for records with these two values till end of file. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
No, that will not do what you want.
How many records are in the file? |
|
Back to top |
|
|
aakar
New User
Joined: 08 Apr 2008 Posts: 36 Location: mumbai
|
|
|
|
Very large number of records(>10000) are there in the file with the same key.
if i use an AIX made out of key2 & key3 and make key1(8 byte) as primary key, then the aix runs out of length.
refer my other post in this reference:
ibmmainframes.com/viewtopic.php?t=35264 |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Not what i asked - how many total records are in the file? |
|
Back to top |
|
|
|