Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Exist clause in PL/SQL
In article <1b00d968.0111120741.6e92e5fb_at_posting.google.com>,
yavior_at_mercury.co.il says...
>
>Hi,
>Is there in PL/SQL any replacement for SQL-Server's "If exist/If not
>exist" clause?
>I need to do something like : if not exists (select * from Table1
>where Field1=...) Insert into Table1 (Field1, Field2,...) values (...,
>...,...)
>
>thanks
if not exists ( select .... )
then
insert ...
end
would be the same as:
for x in ( select * from dual where NOT EXISTS ( select .... ) ) loop
insert ...
end loop;
and
for x in ( select * from dual where EXISTS ( select .... ) ) loop
....
end loop
would be the same as
if exists ( select .... )
-- Thomas Kyte (tkyte@us.oracle.com) http://asktom.oracle.com/ Expert one on one Oracle, programming techniques and solutions for Oracle. http://www.amazon.com/exec/obidos/ASIN/1861004826/ Opinions are mine and do not necessarily reflect those of Oracle CorpReceived on Mon Nov 12 2001 - 14:04:31 CST
![]() |
![]() |