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: 6966
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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


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