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: Decode equivalent within pl/sql?

Re: Decode equivalent within pl/sql?

From: Jeremy <jeremy0505_at_gmail.com>
Date: Mon, 13 Nov 2006 17:22:08 -0000
Message-ID: <MPG.1fc2ba12e695829398a353@news.individual.net>


In article <J8oHux.9xu_at_igsrsparc2.er.usgs.gov>, Brian Peasland says...
> > Thanks I may not have made it clear - I know I can use DECODE in a
> > select stamenet within PL/SQL but I was looking for a nicer way to code
> > the following (example) without having to define a variable into which
> > to put the value I want before calling the proc.
> >
> > e.g
> >
> > begin
> > -- stuff
> > utility_proc(p1 => 'ADD',
> > p2 => decode(thing,'val1','res1','val2','res2','dflt'));
> > --
> > end;
> >
> > Now I know I cannot use the decode there and it seems that I have to
> > look at the value of "thing" using either
> > "if then else"
> > or a
> > "select decode(....) into var from dual;"
> >
> >
>
>
> Note to potential posters....
>
> Please state the thing you are trying to resolve rather than water down
> your example to the point where you are no longer explaining exactly
> what you are trying to achieve. You will find that you get the exact
> answer you are looking for...and get than answer sooner.
>

2nd note to potential posters: I do agree with Brian - I was just being polite when I apologised if I had not been sufficiently succinct.

Actually I think that writing:

"As I understand it you can only use DECODE as part of a SQL statement

e.g. select decode(var,
                   'A','LetterA',
                   'B','LetterB',
                   'Lettersomethingelse')
      from dual;

In a pl/sql statement, you cannot code e.g.

  l_string := decode(.....
"

is fairly unambiguous.

Heck I even included the version number twice in my post :)

But absoulutely - the more clearly you state your problem and lay out examples of what you're trying to achieve, the easier it is for people to help.

-- 
jeremy
Received on Mon Nov 13 2006 - 11:22:08 CST

Original text of this message

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