Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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
No new posts LMINIT problem - not finding DDNAME Danielle.Filteau CLIST & REXX 7 Tue Sep 19, 2017 9:57 pm
No new posts BUILD OUTFIL based on condition other... balaji81_k DFSORT/ICETOOL 13 Fri Sep 08, 2017 11:06 pm
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts JES2 job size field matching Windows ... SRICOBSAS All Other Mainframe Topics 4 Tue Sep 05, 2017 5:49 pm
No new posts Problem commiting to DB2 from IMS MPP Ole Soerensen IMS DB/DC 2 Wed Jul 26, 2017 5:19 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us