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

Indicator variable in SUM statement.


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

New User


Joined: 22 Apr 2006
Posts: 44

PostPosted: Mon Nov 20, 2006 2:04 pm
Reply with quote

Hi Guys,

I have the below query. I believe the below part should not work properly.

Because i feel we should not use indicator varialble, while using aggregate functions. Please ensure my thought is correct or wrong.


EXEC SQL
SELECT SUM (PAY_AMOUNT)
INTO :PAY-AMT :I-1
FROM TMEMBTABLE
WHERE MEMB = :MEMBER-NUM
END-EXEC.

EVALUATE SQLCODE
WHEN +0
IF I-1 < +0
MOVE ZEROS TO PAY-AMT
END-IF
WHEN +100
MOVE ZEROS TO PAY-AMT
END-EVALUATE

Bye
Suresh
Back to top
View user's profile Send private message
callkris_cit

New User


Joined: 22 Apr 2006
Posts: 44

PostPosted: Mon Nov 20, 2006 4:58 pm
Reply with quote

I UNDERSTOOD INDICATOR IS REQUIRED.


BYE

SURESH
Back to top
View user's profile Send private message
vijikesavan

Active User


Joined: 04 Oct 2006
Posts: 118
Location: NJ, USA

PostPosted: Wed Nov 22, 2006 2:43 am
Reply with quote

Hi,
If you dont want to use the indicator, try this.

EXEC SQL
SELECT VALUE (SUM (PAY_AMOUNT),0)
INTO :PAY-AMT
FROM TMEMBTABLE
WHERE MEMB = :MEMBER-NUM
END-EXEC.

This query will make the PAY-AMT zero on null values.
Hope I clarfied you!
Thanks,
Viji
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts variable in library name within a PROC. JCL & VSAM 11
No new posts REXX/CMS How to place command console... CLIST & REXX 4
No new posts how to eliminate null indicator value... DB2 7
No new posts CA7 count with DATE variable CA Products 0
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:


Back to Top