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
 
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: 6970
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 reg query on DYNALLOC feature raghuraman123 SYNCSORT 12 Wed Jan 10, 2018 2:42 pm
No new posts query to fetch record which has only ... maxsubrat DB2 12 Mon Dec 11, 2017 5:03 pm
No new posts How to query MAXGENS of an existing P... Chuchulo Hatyzak JCL & VSAM 4 Wed Nov 22, 2017 10:23 pm
No new posts Native SQL Query kishpra DB2 1 Wed Nov 22, 2017 8:38 pm
This topic is locked: you cannot edit posts or make replies. ISREDIT Macro is not returning back t... nico_neoz CLIST & REXX 21 Sat Nov 18, 2017 7:40 pm

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