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: PL/SQL problem

Re: PL/SQL problem

From: Paul Brewer <paul_at_paul.brewers.org.uk>
Date: Fri, 7 Feb 2003 19:03:30 -0000
Message-ID: <3e4421e1_3@mk-nntp-1.news.uk.worldonline.com>


"Billy Verreynne" <vslabs_at_onwe.co.za> wrote in message news:b1vfin$eok$1_at_ctb-nnrp2.saix.net...
> Paul Brewer wrote:
>
> > Billy,
> >
> > It can be used in SQL statements contained in PL/SQL blocks, but not I
> > think within PL/SQL code.
>
> Paul, I prefer no to "think", but to actually try it and Oracle and see
what
> Oracle "think" about it.
>
> Oracle 8.1.7 on HP-UX.
>
> SQL> create or replace function YNtoTF( yesno char ) return varchar as
> 2 truefalse varchar2(5);
> 3 begin
> 4 select
> 5 decode( upper(yesno), 'Y', 'TRUE', 'FALSE' )
> 6 into truefalse from dual;
> 7 return( truefalse );
> 8 end;
> SQL> /
>
> Function created.
>
> SQL> select
> 2 YNtoTF( 'Y' )
> 3 from dual;
>
> YNTOTF('Y')
> --------------------------------------------------------------------------
-
> TRUE
>
> SQL> select
> 2 YNtoTF('crap')
> 3 from dual;
>
> YNTOTF('CRAP')
> --------------------------------------------------------------------------

--

> FALSE
>
> SQL>
>
>
> Is the above not PL/SQL code using a DECODE function?
>
> Or are we're going to get into semantic definitions of what is PL/SQL
code,
> SQL code, what is not, and crap like that?
>
> The fact is that DECODE *can* be used in PL/SQL. You simply need to know
how
> to use it. Instead of confusing definitions and quoting 3rd party books
> (which surprise, surprise, not all of us have), I would think a poster
with
> a problem would want to know *how* to use the DECODE statement and not
told
> half untruths that DECODE is not a PL/SQL statement, thus implying that it
> can not be used in PL/SQL at all.
>
> --
> Billy
Billy, You and I both know what can and cannot be done with DECODE in PL/SQL. But I would like to apologise if I gave offence; none was intended. And I entirely agree that it's not worth getting bogged down in semantics. Regards, Paul
Received on Fri Feb 07 2003 - 13:03:30 CST

Original text of this message

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