View previous topic :: View next topic
|
Author |
Message |
lalitha_gld
New User
Joined: 12 Jul 2006 Posts: 24
|
|
|
|
Hi,
I'm trying to validate a SMALLINT variable from a DB2 table in my cobol program. I'm fetching it to a S9(04) COMP variable and have to validate against numeric values. If this is possible is the below code valid?
05 WS-NBR-FLG PIC S9(04) COMP.
88 WS-OLD-NBR VALUE 1,2,3.
88 WS-NEW-NBR VALUE 4,5,6,7.
Thanks & Regards,
Lalitha. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
It depends on what the code is you are using. You've shown the field definitions but not the code. |
|
Back to top |
|
|
lalitha_gld
New User
Joined: 12 Jul 2006 Posts: 24
|
|
|
|
If I declare a table - 'TABLE' as
CL# Column name Data type
1 NBR SMALLINT
With the field definitions i had given earlier, this is how am planning to set my code :
EXEC SQL
DECLARE CRSR CURSOR FOR
SELECT NBR FROM TABLE
END-EXEC.
EXEC SQL
OPEN CRSR
END-EXEC.
EXEC SQL
FETCH CRSR
INTO :WS-NBR-FLG
END-EXEC.
EVALUATE TRUE
WHEN WS-OLD-NBR
<PROCESS ONE>
WHEN WS-NEW-NBR
<PROCESS TWO>
WHEN OTHER
PROCESS ERROR PARA TO WRITE ERROR RECORD
END-EVALUATE.
Would this be valid.Pls let me know.
Tx,
Lalitha. |
|
Back to top |
|
|
Raghu navaikulam
Active User
Joined: 27 Sep 2008 Posts: 193 Location: chennai
|
|
|
|
Hi Lalitha
Try to use THRU clause in the 88 level.
Code: |
05 WS-NBR-FLG PIC S9(04) COMP.
88 WS-OLD-NBR VALUE 1 THRU 3.
88 WS-NEW-NBR VALUE 4 THRU 7.
|
Regards
Raghunath |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Using THRU is exactly the same as specifying the individual values to COBOL -- so there's no difference between the original posted code and your "revision", Raghunath. Specifying the values one way or the other is merely a personal preference. |
|
Back to top |
|
|
Srihari Gonugunta
Active User
Joined: 14 Sep 2007 Posts: 295 Location: Singapore
|
|
|
|
Lalitha,
Thats valid. I believe you can easily test this. |
|
Back to top |
|
|
santy Warnings : 1 New User
Joined: 19 Jul 2007 Posts: 22 Location: mumbai
|
|
|
|
Lalitha,
The procedure you are using above is the correct one. It will work. |
|
Back to top |
|
|
|