Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie Question on Coalesce and Char Functs 2

Status
Not open for further replies.

thermidor

Programmer
Joined
Nov 28, 2001
Messages
123
Location
US
Hi All,

I'm new to DB2 but know SQL Server and Oracle well. I'm looking at a definition for a view in a DB2 database and have a question about the line below which is from my view definition

select coalesce(brandid, char(space(4),4)) from mytable

To translate the above into normal English, is the following correct: If brandid is not null, brandid, else ' ' (four spaces).

If this is correct, my question is: Is char(space(4),4) redundant?

TIA,
Sven

 
select coalesce(brandid, ' ') from mytable

is all that is necessary.

This will return brandid if it is present, but 4 spaces if it is null.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top