Example:
CREATE OR REPLACE FUNCTION AAAAA()
RETURN VARCHAR2 IS
BEGIN
DECLARE
rtn_code varchar2(5) := '000';
st_sms_msg varchar2(160) := 'OK';
cursor xxx_cur is
select *
from xxx_details
BEGIN
BEGIN
FOR curSubNo IN xxx_cur
LOOP
wk_detail_totalcount := wk_detail_totalcount + 1;
BEGIN
SELECT *
FROM YYYY
EXCEPTION
WHEN no_data_found THEN
rtn_code := '003';
out_message := ''
GOTO end_loop;
WHEN others THEN
rtn_code := '004';
out_message := '';
RETURN rtn_code;
END;
<<end_loop>>
NULL;
END LOOP;
END;
CLOSE linkDetail_cur;
END;
END;
/
More detail:
https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/controlstructures.htm#BABDBCFF