View previous topic :: View next topic
|
Author |
Message |
cvijay784 Warnings : 1 New User
Joined: 18 Jun 2008 Posts: 54 Location: Colombo
|
|
|
|
Hi,
I am getting an error when using SEARCH ALL. Please see below and help me. Thanks.
WORKING-STORAGE SECTION.
01 WS-NAME PIC X(5).
01 INT-TABLE.
05 BUMKT OCCURS 10 TIMES ASCENDING KEY DATA1 INDEXED BY WS-SUB1.
10 DATA1.
15 NAME PIC X(5).
15 LOCATION PIC X(5).
PROCEDURE DIVISION.
SEARCH ALL BUMKT
AT END
DISPLAY 'MATCH NOT FOUND'
WHEN NAME = WS-NAME
DISPLAY LOCATION
END-SEARCH.
Error Message:
The left side operand, "NAME (ALPHANUMERIC)", of a "WHEN"
phrase of a "SEARCH ALL" statement was not a key of the table being
searched. The statement was discarded. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
The message tells you exactly what is wrong. You defined DATA1 as your key -- so your SEARCH ALL must use DATA1, not NAME, for your WHEN clause. SEARCH ALL does not support partial key searches. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Define some good datanames, please. I'm surprised "NAME" isn't already RESERVED, but it could be someday. Surely the contents of your data are not the only thing worthy of the word NAME in the entire world, so why not describe them a bit better and help out the next person who looks at your program (and you in a week's time) so that they know what "NAME" is. |
|
Back to top |
|
|
cvijay784 Warnings : 1 New User
Joined: 18 Jun 2008 Posts: 54 Location: Colombo
|
|
|
|
Thanks for your reply. Can i have more than 1 field as table key? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Isn't it easy enough to look in the manual? Toss in a compile yourself? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Your question is not clear as worded.
If you are asking whether more than one variable can be specified as the table keys, the answer is yes -- but you must load the table in the correct sequence based on all the keys.
If you are asking whether the ASCENDING (DESCENDING) KEY IS phrase can reference a group variable, the answer is a qualified yes. The manual indicates that a group variable used as a table key cannot have an OCCURS clause nor can it contain any OCCURS DEPENDING ON on any subordinate level. |
|
Back to top |
|
|
|