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

Max function in DB2


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

New User


Joined: 12 Apr 2008
Posts: 36
Location: NOIDA

PostPosted: Mon Dec 21, 2009 11:27 am
Reply with quote

Hi ,

I have requirement like in the below query.
SELECT MAX(ACDFCPNN) FROM TE.UTE01011_ACFTDEFCT
WHERE ACFTABB = WS_ACFTABB
INTO :WS_ACDFCPNN;

I tried to run this query in QMF when the value passed in WS_ACFTABB is not available in table then the query is returning Null value as '-' .
Now then I have rquirement to move Zero to the host variable WS_ACDFCPNN when the query returns null value ie '-'.
Can somebody assist that how to handle this.

Thanks,
Chandan Kapoor
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Mon Dec 21, 2009 12:03 pm
Reply with quote

Hello Chandan,

Please try below query:

Code:
SELECT COALESCE(MAX(ACDFCPNN),0) FROM TE.UTE01011_ACFTDEFCT
WHERE ACFTABB = WS_ACFTABB
INTO :WS_ACDFCPNN;
Back to top
View user's profile Send private message
CHANDAN KAPOOR

New User


Joined: 12 Apr 2008
Posts: 36
Location: NOIDA

PostPosted: Mon Dec 21, 2009 12:21 pm
Reply with quote

Thanks , Ekta for your quick reply.
Back to top
View user's profile Send private message
tamal_babu

New User


Joined: 06 Feb 2006
Posts: 17
Location: Kolkata

PostPosted: Mon Dec 21, 2009 6:46 pm
Reply with quote

u can use VALUE function as well...
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 Calling an Open C library function in... CICS 1
No new posts DATE2 function SYNCSORT 15
No new posts Help on PL/I jsonPutValue function PL/I & Assembler 8
No new posts how to use Tso outtrap external function All Other Mainframe Topics 8
No new posts INSYNC option with same function as I... JCL & VSAM 0
Search our Forums:

Back to Top