Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Null select

Re: Null select

From: Dave Matern <dmatern_at_dtiservices.com>
Date: 2000/05/12
Message-ID: <391c4954_1@news5.newsfeeds.com>#1/1

Offhand I'd say in Oracle you could use the DECODE function so that it decodes a null value into
a NULL and otherwise it performs the concatenation you've got. Like this:

select crcname,
crcexp,
decode(crcardno,"",NULL,

   rpad(substr(crcardno,1,4) || '-' || substr(crcardno,5,4) || '-' ||    substr(crcardno,9,4) || '-' || substr(crcardno,13,4),25,' ') from crcard

Or something very similar...not sure how the NULLs would have to be written.

DECODE is a very handy function.

Dave Matern
DotCom Technologies, Inc.

Kram wrote in message ...
>I am performing the select statement which includes formatting a credit
 card
>number with "-". However, the problem is if the record returns a null the
>"-" the statement still returns "---" is there a better way to perform
 this?
>
>select crcname,
>crcexp,
>rpad(substr(crcardno,1,4) || '-' || substr(crcardno,5,4) || '-' ||
>substr(crcardno,9,4) || '-' || substr(crcardno,13,4),25,' ')
>from crcard
>
>
>

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- Received on Fri May 12 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US