If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Concatenation of Null Values

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-14-05, 02:25
Shefu Shefu is offline
Registered User
 
Join Date: Apr 2005
Posts: 127
Question Concatenation of Null Values

Hi,

I ve a varchar variable(say Var1 ) which may be not initialized or may have a null value., when i concatenate this variable with any other varchar variable (say Var2 = 'SAMPLE') which has a valid string as a value., the result obtained is null.

ie.,

result = var1 || var2 returns null to result

In DB2 is there anything similar to SQL Server's

SET CONCAT_NULL_YIELDS_NULL { ON | OFF }

this option when set to OFF returns the non null string and returns null when set to ON.

Regards
Sn
Reply With Quote
  #2 (permalink)  
Old 12-14-05, 02:43
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Do not know of any such config parm ..

You can do coalesce(var1,'')||coalesce(var2,'')

Cheers
Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 12-14-05, 03:02
Shefu Shefu is offline
Registered User
 
Join Date: Apr 2005
Posts: 127
Thanks for the reply Sathyaram, I ve plenty of such concatenations and hence the usage of COALESCE will be tedious, is there any other work around.

Sn
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On