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
 

 

DB2 query has like in that is returning wrong values

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

New User


Joined: 23 Aug 2006
Posts: 13

PostPosted: Tue Sep 23, 2008 5:49 am    Post subject: DB2 query has like in that is returning wrong values
Reply with quote

Hi ,

I have copy book in my program in which i wrote a sql query as

Code:
SELECT SUM(PROCESS_CNT),                           
       SUM(TOTAL_EVENT_AMT),                       
       SUM(ZB_TTL_PREMIUM_AMT),                   
       SUM(ZB_TTL_FEE_AMT)                         
INTO   :TBBL-PROCESS-CNT :WS-SUM-IND4,             
       :TBBL-TOTAL-EVENT-AMT :WS-SUM-IND1,         
       :TBBL-ZB-TTL-PREMIUM-AMT :WS-SUM-IND2,     
       :TBBL-ZB-TTL-FEE-AMT :WS-SUM-IND3           
FROM   ZB_TTB_BALANCING A                         
WHERE  PROCESS_DT        = CURRENT DATE           
 AND   PROCESS_CD        = :TBBL-PROCESS-CD       
 AND   PROCESS_ITERATION = :TBBL-PROCESS-ITERATION
 AND   PROGRAM_NAME      = :TBBL-PROGRAM-NAME     
 AND   PROCESSING_ACTION = :TBBL-PROCESSING-ACTION
 AND   TARGET_NAME LIKE :TBBL-TARGET-NAME         
WITH UR                                           

I'm passing data to the copy book variables as below:

Code:
MOVE 'O'                      TO TBBL-PROCESS-CD.         
MOVE ZEROS                    TO TBBL-PROCESS-ITERATION.   
MOVE 'ZBO460'                 TO TBBL-PROGRAM-NAME.       
MOVE 'WRITE'                  TO TBBL-PROCESSING-ACTION.   
MOVE ZEROS                    TO TBBL-PROCESS-CNT.         
MOVE ZEROS                    TO TBBL-ZB-TTL-PREMIUM-AMT. 
MOVE "'RGNOC%'"                 TO TBBL-TARGET-NAME.       


It is returning TBBL-PROCESS-CNT , TBBL-TOTAL-EVENT-AMT as zeros where as the same query in QMF returns 3 and 863.45 .

Can any body help me in finding out the error??

Thanks and Regards,
Lakshmi
Back to top
View user's profile Send private message

dick scherrer

Site Director


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

PostPosted: Tue Sep 23, 2008 6:17 am    Post subject:
Reply with quote

Hello,

Why are there both single and double quotes around the literal in the last MOVE?

I'd try without the double quotes. It is not something i can test just now.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Tue Sep 23, 2008 10:58 am    Post subject:
Reply with quote

what is the length of TBBL-TARGET-NAME?

Quote:

where as the same query in QMF ....


That is not true.
it can not be the same query. you can not use host variables in QMF.
Back to top
View user's profile Send private message
lakshmi_ta

New User


Joined: 23 Aug 2006
Posts: 13

PostPosted: Wed Sep 24, 2008 5:14 am    Post subject: Reply to: DB2 query has like in that is returning wrong valu
Reply with quote

Hi Friends,

Thanks for the reply. I didn't use the same query in qmf. Same query i mean to say same select sum( ) not with the host variables, with the hard coded values in Where clause.

I don't know the reason why like 'RGNOC%' failed in the program. but initialized Target_name and used 'RGNOC___' in target name (as the length is 8 bytes). It worked fine.

Thanks and Regards,
Lakshmi
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 BI,TO=ZD Changing Values Tyler Dunbar DFSORT/ICETOOL 1 Tue Jul 25, 2017 12:12 am
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 19 Thu Jul 13, 2017 2:11 pm
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm


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