As mentioned by question commentators, this is used to refer to compound statements, and also as a target for GOTO. You can use this label in END and END LOOP, which can be readable, for example, <<countdown>> for i in 1.9 loop blah; end loop countdown;
<<countdown>> for i in 1.9 loop blah; end loop countdown;
Here is an example:
set echo on set serveroutput on <<begin_end_block>> declare msg varchar2(1000); begin dbms_output.enable; msg := chr(9) || 'start'; <<loopblk>> for itr8 in 1 .. 5 loop msg := msg || chr(10) || chr (9) || 'loop'; dbms_output.put_line ('Iterator is ' || itr8); <<ifblck>> if itr8 > 2 then msg := msg || chr(10) || chr(9) || 'greater than 2'; goto gototarg; end if; exit loopblk when mod (itr8, 4) = 0; continue loopblk; <<gototarg>> dbms_output.put_line ('after goto target'); end loop loopblk; dbms_output.put_line ('Ending, here are the messages' || chr(10) || msg); end begin_end_block; /
:
anonymous block completed Iterator is 1 Iterator is 2 Iterator is 3 after goto target Iterator is 4 after goto target Iterator is 5 after goto target Ending, here are the messages start loop loop loop greater than 2 loop greater than 2 loop greater than 2
source share