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

Home -> Community -> Usenet -> c.d.o.server -> Re: oracle 9i sql DECODE

Re: oracle 9i sql DECODE

From: IM <ian_at_ianmurphy.freeserve.co.uk>
Date: 19 Sep 2006 04:01:55 -0700
Message-ID: <1158663715.266045.68680@b28g2000cwb.googlegroups.com>

abhishek.ankur_at_gmail.com wrote:
> Hi everyone,
> I want to know that can we check for NULL and NOT NULL conditions in
> DECODE
> like the syntax for DECODE is
> DECODE(expr,value,substitution)
> What I am doing is use some value in expr which needs to be checked for
> NULL and NOT NULL. If the expr is NULL then some value should be used
> for expr and if it is not null then some other value should be used.
>
> CAn this be done???? and if yes how??
> plz help

SQL> select version from v$instance;

VERSION



9.2.0.1.0

SQL> drop table t;

Table dropped.

SQL> create table t (t1 varchar2(10));

Table created.

SQL> insert into t values ('');

1 row created.

SQL> insert into t values ('BOB');

1 row created.

SQL> select decode(t1, null, 'THIS IS NULL', t1)   2 from t;

DECODE(T1,NU



THIS IS NULL
BOB SQL> Hope this helps.

Regards,
IM Received on Tue Sep 19 2006 - 06:01:55 CDT

Original text of this message

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