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

Using Work Variables in COALESCE


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

New User


Joined: 26 Nov 2008
Posts: 13
Location: UK

PostPosted: Wed Dec 17, 2008 8:31 pm
Reply with quote

Hi,

I am trying to use COLAESCE in one of my select SQLs. I would explain the problem i am facing with an example,

Code:
SELECT COALESCE(MAX(MARK),100)           
FROM   <DB2TABLE>
WHERE  NAME = :WS_NAME


The above SQL would work fine. It would return either MAX(MARK) or 100.

My question is, if I have 100 in a working storage variable(e.g. WS_SCORE), would I be able to do something like,

Code:
SELECT COALESCE(MAX(MARK),:WS_SCORE)           
FROM   <DB2TABLE>
WHERE  NAME = :WS_NAME


I think the above SQL would not work, as I get SQLCODE -171. But can anyone let me know if I can pass :WS_SCORE like above or in any other way using COALESCE?

Thanks.
Back to top
View user's profile Send private message
ikumar

New User


Joined: 02 Aug 2005
Posts: 81

PostPosted: Thu Dec 18, 2008 11:15 am
Reply with quote

Why don't you try it using host variable instead of WS variable...
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 isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts JCL with variables JCL & VSAM 1
No new posts JCL Variables JCL & VSAM 1
No new posts reset/clear ALL application profile v... TSO/ISPF 3
No new posts REXX - Adding variables CLIST & REXX 8
Search our Forums:

Back to Top