Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exit stored procedure 2

Status
Not open for further replies.

jluost1

Programmer
Jun 8, 2001
78
US
How do I stop execution inside a stored procedure immediately after a certain line, just like EXIT does in a loop?

What I need is:
-------------------
procedure my_procedure()
is
begin
...
IF my_cursor%NOTFOUND THEN
-- exit;
end if;
...
end;
----------------------
Thanks.
 
The first way that I can think of would be to raise an exception whose handler does nothing:

DECLARE
x_exit EXCEPTION;
BEGIN
.
.
.
RAISE x_exit;
.
.
.
EXCEPTION
WHEN x_exit THEN
null;
END;

 
You may use the RETURN statement. However it's not best programming practice to have multipe exitpoints in a subprogram.

Stefan
 
RETURN! THAT'S the one I was trying to remember!! Thank-you, Stefan, it was really bothering me!

And I have to agree with you - it's better to design your code so that it only has one exit point.
 
Return may be the academically correct answer. Carp provided the solution how this problem should be handled - with exception your code stays a bit more readable. So I think the star more belongs to carp.

Stefan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top