PL / SQL What does a word mean?

What does a word in double angle brackets mean in PL / SQL, for example. <<word>> ?

I tried to do a google search, but google skips punctuation.

What is it used for?

+6
source share
2 answers

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 
+2
source

The syntax <> is for naming loops. Useful when you have nested loops and you need to use EXIT loop_name WHEN ... syntax to control which loop will come out.

See http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/controlstructures.htm#BABJCCFJ for an example

0
source

Source: https://habr.com/ru/post/907225/


All Articles