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

Home -> Community -> Usenet -> c.d.o.misc -> Re: A simple PL/SQL question...

Re: A simple PL/SQL question...

From: Richard Kuhler <noone_at_nowhere.com>
Date: Sat, 15 May 2004 02:04:41 GMT
Message-ID: <ZUepc.52836$BG1.32493@twister.socal.rr.com>


Aiden Fung wrote:
> Hi all,
>
> I'm trying to port a SQL Sever application to Oracle. How do I write the
> following statement in PL/SQL?
>
> IF EXISTS(SELECT 1 FROM table_x WHERE column_a = 'X')
> ... do stuff

Here's one of many ways to do it ...

count integer;
...
select count(*)
into count
from x
where column_a = 'X'

   and rownum = 1;

if count > 0 then

   do stuff
end if;

--
Richard Kuhler
Received on Fri May 14 2004 - 21:04:41 CDT

Original text of this message

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