Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Problem with condition checking in a VARCHAR DB2 field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
jothibso

New User


Joined: 03 Sep 2009
Posts: 18
Location: chennai

PostPosted: Mon Dec 12, 2011 2:20 pm    Post subject: Problem with condition checking in a VARCHAR DB2 field
Reply with quote

Hi,

I have a varchar(100) field say Field5 in a DB2 table which is loaded by a third party. In my SP am using this field in the inner query

Code:

EXEC SQL                                                 
   SELECT                                                 
      C.Field1 ,C.Field2                                   
   INTO                                                   
      :WS-A ,:WS-B                   
   FROM                                                   
      TABLE1  A, TABLE2  B, TABLE3  C                                 
   WHERE                     
       A.Field1   = C.Field1 AND                                       
       A.Field3   = B.Field3 AND                                 
       C.Field1 IN                   
      (SELECT Field1 FROM TABLE3
       WHERE  Field4     = 1290             
       AND    Field5    ¬= '0001')
END-EXEC     

If Field5 is having value 0001 then Field5 len --> 4 and Field5 Text--> 0001 (remaining 96 bytes are spaces)
Scenario 1
In other cases Field5 had Field5 len --> 4 and Field5 Text --> low-values for all 100 bytes
Scenario 2
There was a new data update by the third party recently after which Field5 had the following values other than 0001 Field5 len --> 0 and Field5 Text --> Null

For Scenario 1 the above query worked whereas after data update for Scenario 2 the query did'nt work, and we had to revert back the changes.
Since we are getting the data from 3rd party we are trying to fix it from our side if possible before going back to them. We thought of doing a 1 time update however the third party does a weekly refresh, so the 1 time changes we make may not last

1. Is there any way to check for Field5 ¬= '0001' if the DB has NULL values in SP
2. Is it mandatory for the Field5 len to be 4 since we are checking 4 byte value '0001' in the query

Please help
Back to top
View user's profile Send private message

Nandhu86

New User


Joined: 03 Jun 2009
Posts: 1
Location: Chennai

PostPosted: Mon Dec 12, 2011 4:45 pm    Post subject: Re:Problem with condition checking in a VARCHAR DB2 field
Reply with quote

Try this query for checking NULL values

Code:

EXEC SQL                                                 
   SELECT                                                 
      C.Field1 ,C.Field2                                   
   INTO                                                   
      :WS-A ,:WS-B                   
   FROM                                                   
      TABLE1  A, TABLE2  B, TABLE3  C                                 
   WHERE                     
       A.Field1   = C.Field1 AND                                       
       A.Field3   = B.Field3 AND                                 
       C.Field1 IN                   
      (SELECT Field1 FROM TABLE3
      AND (Field5    ¬= '0001' OR
   FIELD5 IS NULL))
END-EXEC 
Back to top
View user's profile Send private message
jothibso

New User


Joined: 03 Sep 2009
Posts: 18
Location: chennai

PostPosted: Mon Dec 12, 2011 5:25 pm    Post subject:
Reply with quote

Thanks Nandhu it worked
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Need help on If condition continuatio... ashok_uddaraju CLIST & REXX 4 Fri May 19, 2017 8:55 am
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts Alter &DATENS field in HEADER1 Angad DFSORT/ICETOOL 4 Mon Apr 24, 2017 11:49 am
No new posts Strings with double quotes having pro... raja Arumugam All Other Mainframe Topics 11 Thu Mar 30, 2017 10:34 am
No new posts Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us