Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: A simple PL/SQL question...
"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
![]() |
![]() |