View previous topic :: View next topic
|
Author |
Message |
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
Hi All,
Can I use an 88 Level variable which can have multiple values in a WHERE clause.
For Ex: My 88 Level variable definition is as:
Code: |
05 WS-STATUS PIC S9(2) COMP-3.
88 WS-VALID-STATUS VALUES +01, +02, +03,
+04, +05, +08,
+09, +10, +11
+12.
88 WS-INVALID-STATUS VALUES +06, +07. |
I know, I can use WHERE VALUE IN, but I was just wondering if I can use it like this:
Code: |
SET WS-VALID-STATUS TO TRUE. |
And in SQL Query as:
Code: |
WHERE STATUS = :WS-STATUS. |
I just can't test it now, that's why I'm posting here.
Thanks
Neeraj. |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
No |
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
Thanks GuyC |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
When you SET ... TO TRUE the data-name gets the first value from the 88, so that the 88 will be "true". The data-name can only have one value. |
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
Thanks Bill.
But then how does this work in IF statements.
Code: |
MOVE +2 TO WS-STATUS.
IF WS-VALID-STATUS
.......................
.......................
ELSE
.......................
.......................
END-IF. |
I used it like below and it's working.
Code: |
WHERE STATUS IN ( :WS-STATUS) |
Thanks. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I used it like below and it's working. |
For which values of :ws-status? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
You have made a fairly common mistake. WS-VALID-STATUS and WS-INVALID-STATUS are not variable in COBOL They are called conditionals and cannot be considered variables. Hence you cannot use one as a host variable. If you expand your IF statement by using the LIST option in your COBOL compile, you will see your IF WS-VALID-STATUS actually expands into a series of pseudo-assembler statements, each one comparing the value of WS-STATUS against one of the values the conditional references. |
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
Thanks everyone for your valuable suggestions.
I didn't get a chance to test properly. May be I have missed tsomething. We are having some problem with the Changeman. Yesterday they fixed the problem, but that was momentary. So currently I can't compile or bind, until the problem is resolved.
I will do a proper testing and update my results here.
Thanks again.
Neeraj. |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
only thing that slightly looks like what you want is :
Code: |
01 WS-VALID-STATUS-INLIST.
05 WS-VS-01 PIC S9(4) COMP value +04.
05 WS-VS-02 PIC S9(4) COMP value +05.
05 WS-VS-03 PIC S9(4) COMP value +08.
05 WS-VS-04 PIC S9(4) COMP value +09.
05 WS-VS-05 PIC S9(4) COMP value +10.
05 WS-VS-06 PIC S9(4) COMP value +11.
05 WS-VS-07 PIC S9(4) COMP value +12.
...
EXEC SQL
...
WHERE STATUS IN (:WS-VALID-STATUS-INLIST)
END-EXEC |
|
|
Back to top |
|
|
mistah kurtz
Active User
Joined: 28 Jan 2012 Posts: 316 Location: Room: TREE(3). Hilbert's Hotel
|
|
|
|
Hi All,
Quote: |
I used it like below and it's working.
Code: |
WHERE STATUS IN ( :WS-STATUS) |
|
Finally the Changeman problem was resolved and I tested my program. I was wrong. It was not giving me desired output.
I used the way GuyC has suggested and it's working fine.
Thank you all for your help and guidance. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Good to hear it is working - thank you for the testing and followup
d |
|
Back to top |
|
|
|