PL / SQL中双角括号中单词的含义是什么,例如。 <<word>>
?
我试图进行谷歌搜索,但谷歌会跳过标点符号。
它用于什么?
答案 0 :(得分:2)
如问题评论者所述,这用于标记复合语句以及GOTO的目标。您可以使用END和END LOOP中的标签来提高可读性,例如<<countdown>> for i in 1.9 loop blah; end loop countdown;
以下是一个例子:
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
答案 1 :(得分:0)
&lt;&gt;语法用于命名循环。当你有嵌套循环并需要使用EXIT loop_name WHEN ...语法来控制退出哪个循环时很有用。
请参阅http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/controlstructures.htm#BABJCCFJ以获取示例