PL/SQL中双尖括号中单词的含义是什么,例如。 <<word>>
?
我试图进行谷歌搜索,但谷歌跳过标点符号。
它是干什么用的?
最佳答案
正如问题评论者提到的那样,它用于标记复合语句,也用作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