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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Adding 'ODD' and 'EVEN' indicator at ... DFSORT/ICETOOL 6
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top