How to exit stored procedure

Database
Enthusiast

How to exit stored procedure

Hi,
in my TD stored procedure i want to exit the stored procedure when certain if condition is met.
There are a lot of statements after the if the clause and i don't want to go ahead with those.

if then
...
elseif then
...
exit;
elseif then
...
end if;
...
...

I tried using 'exit', 'return', 'quit' and they don't work.
In short i want to exit the stored proecdure at the current statement gracefully.

Thanks,
-srinivas yelamanchili

2 REPLIES
Enthusiast

Re: How to exit stored procedure

Neither the SQL standard nor Teradata defines a return or exit statement for a stored procedure. However, you can use LEAVE with a statement label to achieve a similar effect. See the Teradata publication, "SQL Reference: Stored Procedures and Embedded SQL".
Enthusiast

Re: How to exit stored procedure

Thanks Jim,
i used another BEGIN/END with label and used LEAVE on this lable.
It worked.
Thanks again,
-srinivas