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
 

 

Substituting NULL values in a SELECT query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
vickyprodigy

New User


Joined: 18 Jul 2007
Posts: 11
Location: Chennai

PostPosted: Wed Sep 26, 2007 2:38 pm    Post subject: Substituting NULL values in a SELECT query
Reply with quote

Hi,

I generate reports from Error log tables. Wat i do is... i run a SELECT query based on certain conditions and i FTP the result in a TXT format. When i FTP it, the records which has NULL in the table is getting overwritten by the values of the subsequent column. To prevent this, i need a way to substitute someother value (eg '-' ) for the NULL values. Is it possible to do it in the SELECT query itself????
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Sep 26, 2007 3:03 pm    Post subject:
Reply with quote

COALESCE
Back to top
View user's profile Send private message
vickyprodigy

New User


Joined: 18 Jul 2007
Posts: 11
Location: Chennai

PostPosted: Wed Sep 26, 2007 3:23 pm    Post subject:
Reply with quote

Can you explain please
Back to top
View user's profile Send private message
vickyprodigy

New User


Joined: 18 Jul 2007
Posts: 11
Location: Chennai

PostPosted: Wed Sep 26, 2007 3:26 pm    Post subject:
Reply with quote

thanks got it...

also...

can somebody tell ... how do i make the result of a varchar column of same length in a SELECT query...


Thanks
Back to top
View user's profile Send private message
Ajay Baghel

Active User


Joined: 25 Apr 2007
Posts: 205
Location: Bangalore

PostPosted: Wed Sep 26, 2007 3:31 pm    Post subject: Reply to: Substituting NULL values in a SELECT query
Reply with quote

Or use 'SELECT VALUE(COLX,value)'

Whenever COLX column has null, it is substituted by value.
Back to top
View user's profile Send private message
mbr_raja

New User


Joined: 15 Nov 2004
Posts: 26
Location: Chennai, India

PostPosted: Wed Sep 26, 2007 3:39 pm    Post subject: Reply to: Substituting NULL values in a SELECT query
Reply with quote

Hi,

You can use this function as given below. By using the IFNULL function, you can able to findout null values and replace with given specific strings. It can also be used to specify multiple columns within a single select query.

SELECT EMPNO, IFNULL(SALARY, '-') FROM ADMINISTRATOR.EMP;
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 Join in SQL Query vickey_dw DB2 1 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


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