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: Jim Kennedy <kennedy-downwithspammersfamily_at_attbi.net>
Date: Sat, 15 May 2004 01:52:13 GMT
Message-ID: <hJepc.51517$iF6.4677599@attbi_s02>

"Aiden Fung" <aidenf_at_pacbell.net> wrote in message news:7Udpc.48609$wc.44748_at_newssvr29.news.prodigy.com...
> 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
>
> The main purpose of the statement is to test if a record exists.
>
> Thanks in advance,
> Aiden
>
>

You can do a for loop.

for x in (SELECT 1 FROM table_x WHERE column_a = 'X' and rownum<2) loop ....
end loop;

I added the rownum<2 in case you returned more than 1 row. I assume you want it to do it or not 1 time.

Jim Received on Fri May 14 2004 - 20:52:13 CDT

Original text of this message

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