IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Db2 query. Unexpected result. Need Explanation.


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Mukesh Pandey

Active User


Joined: 11 Nov 2008
Posts: 143
Location: India

PostPosted: Tue Nov 24, 2009 3:52 pm
Reply with quote

hi all please find the below db2 query.

Code:
SELECT                                                               
      A.CLM_NUM_CD,                                                 
      A.UPDT_TS,                                                     
      M.SITUS_ST                                                     
FROM                                                                 
 F3696DB.TUDCLINF A,                                                 
 F3696DB.TUDEMPLR M                                                 
WHERE                                                               
      A.RPRT_NUM = M.RPRT_NUM                                       
        AND A.CLM_NUM_CD = '200910138950'                           
       --   AND (M.SITUS_ST IN ('NY',' ') OR  (M.SITUS_ST IS NULL)) 
                                                                     
WITH UR;   


o/p

Code:
CLM                                           
NUM                   UPDT                                    SITUS
CD                     TS                                        ST   
------------        ------------------------                -----
222222222222  2009-11-02-14.25.24.555555     



Code:
SELECT                                                               
      A.CLM_NUM_CD,                                                 
      A.UPDT_TS,                                                     
      M.SITUS_ST                                                     
FROM                                                                 
 F3696DB.TUDCLINF A,                                                 
 F3696DB.TUDEMPLR M                                                 
WHERE                                                               
      A.RPRT_NUM = M.RPRT_NUM                                       
        AND A.CLM_NUM_CD = '200910138950'                           
          AND (M.SITUS_ST IN ('NY',' ') OR  (M.SITUS_ST IS NULL)) 
                                                                     
WITH UR;


o/p

Code:
CLM                                             
NUM           UPDT                           SITUS 
CD             TS                               ST   
------------  --------------------------  -----     



Can i know why no row is fetched in the second query.


Thanks in advance
Back to top
View user's profile Send private message
Mukesh Pandey

Active User


Joined: 11 Nov 2008
Posts: 143
Location: India

PostPosted: Tue Nov 24, 2009 3:59 pm
Reply with quote

The STS_ST is blank in first o/p . the second query gives 0 rows when sts_st is queried for spaces or blank.
Back to top
View user's profile Send private message
Mukesh Pandey

Active User


Joined: 11 Nov 2008
Posts: 143
Location: India

PostPosted: Tue Nov 24, 2009 5:08 pm
Reply with quote

i am getting the hex value of of SITUS code as 00
00

Can i know what is the value of 00
00
Back to top
View user's profile Send private message
Mukesh Pandey

Active User


Joined: 11 Nov 2008
Posts: 143
Location: India

PostPosted: Tue Nov 24, 2009 5:46 pm
Reply with quote

the field in STITUS_ST is neither NULL nor SPACES. what query will fetch these values keeping in mind i need to give suggestion for the time being. i cant change data.
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Tue Nov 24, 2009 6:06 pm
Reply with quote

Code:
column IS NOT NULL
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Nov 24, 2009 7:54 pm
Reply with quote

"the field in STITUS_ST is neither NULL nor SPACES. what query will fetch these values keeping in mind i need to give suggestion for the time being. i cant change data."

The column is not nullable but it contains a x'00' which is a valid character but it is not a space (x'40'). Suggest you look at the application that loaded the data in the first place.
Back to top
View user's profile Send private message
Mukesh Pandey

Active User


Joined: 11 Nov 2008
Posts: 143
Location: India

PostPosted: Wed Nov 25, 2009 12:11 pm
Reply with quote

Thanks Craq. I will do that.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Wed Nov 25, 2009 1:29 pm
Reply with quote

Hello Mukesh,

Are you sure that you are getting followng output of First query?

Code:
CLM                                           
NUM                   UPDT                                    SITUS
CD                     TS                                        ST   
------------        ------------------------                -----
[b]222222222222[/b]  2009-11-02-14.25.24.555555   


As in the query you have specified A.CLM_NUM_CD = '200910138950'
in the predicate then output record should have 200910138950 as CLM_NUM_CD

Code:
SELECT                                                               
      A.CLM_NUM_CD,                                                 
      A.UPDT_TS,                                                     
      M.SITUS_ST                                                     
FROM                                                                 
 F3696DB.TUDCLINF A,                                                 
 F3696DB.TUDEMPLR M                                                 
WHERE                                                               
      A.RPRT_NUM = M.RPRT_NUM                                       
     [b]   AND A.CLM_NUM_CD = '200910138950'  [/b]                         
       --   AND (M.SITUS_ST IN ('NY',' ') OR  (M.SITUS_ST IS NULL)) 
                                                                     
WITH UR;   
Back to top
View user's profile Send private message
Mukesh Pandey

Active User


Joined: 11 Nov 2008
Posts: 143
Location: India

PostPosted: Mon Nov 30, 2009 11:07 am
Reply with quote

hi Craq and others please clear my below doubt..

IF PLN-SITUS-ST > SPACES
MOVE PLN-SITUS-ST TO EMPLR-SITUS-ST
ELSE
MOVE SPACES TO EMPLR-SITUS-ST
END-IF.

WILL THE ABOVE CODE CHECK FOR ALL LOW VALUES AND AVOID IT GETTING POPULATED IN THE VAR EMPLR-SITUS-ST ?

I WANT TO AVOID HEX( ) AND USE '>' OPERATOR IN MY COBOL PROGRAM FOR SIMPLICITY.

PLEASE ADVICE.


Thanks in advance,
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Nov 30, 2009 11:29 am
Reply with quote

Hello,

If you are only interested in preventing low-values (x'00'), you might consider creating a working-storage item called ws-low-valu and give a VALUE of x'00'. Then your IF can be a simple = comparison.
Back to top
View user's profile Send private message
Mukesh Pandey

Active User


Joined: 11 Nov 2008
Posts: 143
Location: India

PostPosted: Mon Nov 30, 2009 11:36 am
Reply with quote

Hi dick, Thanks for your suggestion. i understand what you suggest.

Also please advice if my code will bypass all the low values or not.

IF PLN-SITUS-ST > SPACES
MOVE PLN-SITUS-ST TO EMPLR-SITUS-ST
ELSE
MOVE SPACES TO EMPLR-SITUS-ST
END-IF.


Thanks,
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Nov 30, 2009 11:13 pm
Reply with quote

Hello,

Quote:
Also please advice if my code will bypass all the low values or not.
I don't understand what this is asking? What does "all the low values" mean? There is only 1 low-value. . .

A space is an x'40' which will always compare higher than an x'00'. If there are other non-displayable values, comparing for greater than spaces would not be sufficient.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts first column truncated in search result IBM Tools 13
Search our Forums:

Back to Top