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
 

 

Indicator variable in SUM statement.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Indicator variable in SUM statement.
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    Post subject: Re: Indicator variable in SUM statement.
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    Post subject: Re: Indicator variable in SUM statement.
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    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 -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts COBOL DB2 - CALL statement - high CPU... TS70363 DB2 15 Sun Sep 11, 2016 6:07 am
No new posts Converting NULL column into NOT NULL ... Raghu navaikulam DB2 5 Sat Aug 06, 2016 3:45 pm
This topic is locked: you cannot edit posts or make replies. Updating value of key using rewrite s... ParminderKumar COBOL Programming 4 Thu Aug 04, 2016 12:46 am


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