469,089 Members | 1,210 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,089 developers. It's quick & easy.

If exists in PL/sql

Hi Guys

I am a bit of a nocice at some aspects of PL/SQL and I have to write some
code in a function that checks if a row in a given table exists...something
on the lines of :

IF( exists(select 'x' from table) then
do stuff
else
do other stuff

end if;

Is there a quick and efficient way of doing this?

Thnx

Paulos
Jul 19 '05 #1
1 91569
Hi

DECLARE
l_count NUMBER;
BEGIN
select count(*)
into l_count
from all_tables
where table_name = 'ur_table';

if l_count > 0 then
do somthing;
end if;
END;

another way would be very simply

begin
select 'X' from ur_table;
do something
exception
write exception handling code
end

regards
Hrishy


"Paulos" <pa*************@skynet.be> wrote in message news:<40**********************@news.skynet.be>...
Hi Guys

I am a bit of a nocice at some aspects of PL/SQL and I have to write some
code in a function that checks if a row in a given table exists...something
on the lines of :

IF( exists(select 'x' from table) then
do stuff
else
do other stuff

end if;

Is there a quick and efficient way of doing this?

Thnx

Paulos

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Trev | last post: by
15 posts views Thread by Geiregat Jonas | last post: by
18 posts views Thread by Dan | last post: by
4 posts views Thread by DEWright_CA | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.