I have a stored procedure which runs a series of stored procedure. Each procedure will insert into a table which has the column status and Err_msg. So if I run the 1st procedure and the status shows 'Failed' with the error message, I want to exit the procedure completely. How do I do that?
2 Answers
1
votes
To exit from a procedure in PL/SQL we use a simple RETURN
statement.
If I have assumed correctly, field3 is an OUT
parameter of each of your procedure called inside your main procedure.
CREATE OR REPLACE PROCEDURE sequence_test
AS
field3 VARCHAR2(200) := 'Success';
BEGIN
MARS_TRUNCATE_TABLES('test','test',field3);
IF field3 like 'Failed%' THEN -- use = 'Failed' if it has only that.
RETURN; --exit the procedure completely.
END IF;
MARS_INSERT_TABLE('test','test',field3);
IF field3 like 'Failed%' THEN
RETURN;
END IF;
-- ...
-- ... Similar statements for other procedure calls.
END;
/
-2
votes