Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

exit from a pl/sql block

Fabrizio Delli PriscoliNov 29 2010 — edited Nov 30 2010
Hi all. I'm on oracle 9i.

I have a problem: I launch my sql file, which has a part made of some SQL commands and then inside it there is a part that is a PL/SQL block.
What I want is that if a certain if condition is verified it must exit from PL/SQL block and also it must exit from all the file!

Here is a part of code:

drop table test1;
create table test1
as select * from test2;

create table prova_test1
as select * from test_1
where 1=2;


DECLARE
conta number := 0;
valore number := 0;
contap number := 0;
valorep number := 0;
istruzione varchar2(2000) := null;
BEGIN


select count(1), sum(val) into contap,valorep
from prova_test1;

select count(1), sum(val) into conta,valore
from test_1;
if conta <> contap or valore <> valorep then

istruzione := 'exit';
execute immediate istruzione;
else
others sql statements.....
....
....
end if;
end;
/

So what I want is that if the condition is verified it must exit from pl/sql block and also from all the process.
How can I achieve that??
Thanks for collaboration,
Fabrizio
This post has been answered by Billy Verreynne on Nov 30 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 28 2010
Added on Nov 29 2010
19 comments
16,598 views