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: case when ... then expression

Re: case when ... then expression

From: Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk>
Date: Mon, 25 Jun 2001 20:21:51 +0100
Message-ID: <993496740.18559.1.nnrp-14.9e984b29@news.demon.co.uk>

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
>
>
Received on Mon Jun 25 2001 - 14:21:51 CDT

Original text of this message

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