View previous topic :: View next topic
|
Author |
Message |
Manicka Yazhini T
New User
Joined: 01 Jun 2011 Posts: 7 Location: INDIA
|
|
|
|
Hi,
I have defined a VSAM with Key length 48 from position 0. And defined an AIX key with length 36 from position 0 again.
COBOL compiler throws an error during compiling
"ALTERNATE RECORD KEY" had the same leftmost character position as that of the "RECORD KEY" for this file. The "ALTERNATE RECORD KEY" was discarded.
How can I overcome this error?
I had two alternative options that I can do to overcome this -
1. Define a dummy field in 1st byte and include that as a part of primary key only.
2. Ignore the usage of AIX and go a head with normal VSAM options.
I need to know which one would be the best.? I have more than 3000 duplicates occuring for AIXs. AIX is non-uinque key. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
It sounds like a different design may be in order. . .
If the main key is 48 bytes, why might the first 36 also need to be unique? Why is there a key for the first 36? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
how much of the 36 char aix key will you have?
What are the file attributes which constitute a duplicate aix,
how many dups are there within a prim-key ?
why not prefill the prim-key with what ever you have,
do a start,
and then read. first read next will be an aix hit.
unless there is some overwhelming reason,
i would drop the aix and use the prim.
normally, an aix is based on other fields and not a partial of the primary,
especially starting from the high order.
and no, it would not be a good idea to add a dummy char to the primkey. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Quote: |
2. Ignore the usage of AIX and go a head with normal VSAM options. |
You have no need of an AIX (in Cobol) if it is just a beggining portion of the actual key. You can do what you want with START and READ NEXT, normal VSAM as you put it. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
From the COBOL Language Reference manual (link at the top of the page), section 4.2.10 on the ALTERNATE RECORD KEY clause:
Quote: |
The leftmost character position of data-name-3 must not be the same as the leftmost character position of the prime RECORD KEY or of any other ALTERNATE RECORD KEY. |
So to answer your question, you cannot overcome this error. You must either use the primary key to do generic reads, or you must rethink your entire approach so as not to attempt to use the alternate index you want to -- either by changing your program logic, or by adding data to the record so you can place the alternate index somewhere else in the record. |
|
Back to top |
|
|
Manicka Yazhini T
New User
Joined: 01 Jun 2011 Posts: 7 Location: INDIA
|
|
|
|
Thanks All..!! I have to re-think on the approach. |
|
Back to top |
|
|
|