Using an EXIT Statement
DECLARE
credit_rating NUMBER := 0;
BEGIN
LOOP
credit_rating := credit_rating + 1;
IF credit_rating > 3 THEN
EXIT; -- exit loop immediately
END IF;
END LOOP;
-- control resumes here
dbms_output.Put_line('Credit rating: '
||To_char(credit_rating));
IF credit_rating > 3 THEN
RETURN; -- use RETURN not EXIT when outside a LOOP
END IF;
dbms_output.Put_line('Credit rating: '
||To_char(credit_rating));
END;
/
0 comments:
Post a Comment