Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: case when ... then expression
Jonathan Lewis wrote:
> PL/SQL often lags a little behind SQL in what
> the parser understands. (Though this will never
> happen again after 9i, they say).
>
> For pure PL/SQL programming, how about:
>
> if ( condition1) then
> elsif (condition2) then
> ....
> end if;
>
> For using the CASE statement in a SQL
> statement inside a PL/SQL block you will
> probably have to hide the SQL from PL/SQL
> by using 'execute immediate' with a string.
>
> --
> Jonathan Lewis
>
> Host to The Co-operative Oracle Users' FAQ
> http://www.jlcomp.demon.co.uk/faq/ind_faq.html
>
> Author of:
> Practical Oracle 8i: Building Efficient Databases
> See http://www.jlcomp.demon.co.uk/book_rev.html
>
> Seminars on getting the best out of Oracle
> See http://www.jlcomp.demon.co.uk/seminar.html
>
> Nicolas MUGNIER wrote in message ...
> >Hi,
> >
> >How can I use the CASE WHEN ... THEN expression in a PL/SQL block ?
> >
> >I'v the following statement:
> >INSERT INTO table(id, word) VALUES (ID, CASE WHEN x>1 THEN 'Word1' WHEN
x>2> >
> >THEN 'Word2' ELSE 'Word3' END);
> >
> >This statement works on command line but it doesn't in a PL/SQL block or in
> >a stored procedure.
> >Can somebody help me ?
> >
> >Thanks
> >
> >nunch
What's wrong with DECODE? That is the PL/SQL equivalent.
Daniel A. Morgan Received on Mon Jun 25 2001 - 15:26:26 CDT