<<label_name>>
label的三个地方
<<outer>> -- label
DECLARE
birthdate DATE := ‘09-AUG-70‘;
BEGIN
DECLARE
birthdate DATE := ‘29-SEP-70‘;
BEGIN
IF birthdate = outer.birthdate THEN
DBMS_OUTPUT.PUT_LINE (‘Same Birthday‘);
ELSE
DBMS_OUTPUT.PUT_LINE (‘Different Birthday‘);
END IF;
END;
END outer;
/
Result:
Different Birthday
说明
<<lable_name>> ----- 开始
declare
..... -------可以使用label标识变量
begin
....
end lable_name;
goto label_name
某处
<<label_name>>
DECLARE
done BOOLEAN;
BEGIN
FOR i IN 1..50 LOOP
IF done THEN
GOTO end_loop;
END IF;
<<end_loop>>
NULL;
END LOOP;
END;
/
<<label_name>>的位置有些限制:
exit和continue语句都支持label
DECLARE
s PLS_INTEGER := 0;
i PLS_INTEGER := 0;
j PLS_INTEGER;
BEGIN
<<outer_loop>>
LOOP
i := i + 1;
j := 0;
<<inner_loop>>
LOOP
j := j + 1;
s := s + i * j; -- Sum several products
EXIT inner_loop WHEN (j > 5);
EXIT outer_loop WHEN ((i * j) > 15);
END LOOP inner_loop;
END LOOP outer_loop;
DBMS_OUTPUT.PUT_LINE
(‘The sum of products equals: ‘ || TO_CHAR(s));
END;
/
原文:https://www.cnblogs.com/fqguo24/p/12896564.html