传说中ORACLE11G有BREAK语句了,为什么我无效?

[复制链接]
查看11 | 回复4 | 2010-3-1 11:19:06 | 显示全部楼层 |阅读模式
BEGIN
FOR i IN 1 .. 5
LOOP
IF i = 3
THEN
BREAK;
END IF;
DBMS_OUTPUT.PUT_LINE (i);
END LOOP;
END;
11G到底支持不支持BREAK语句呢?

回复

使用道具 举报

千问 | 2010-3-1 11:19:06 | 显示全部楼层
听说有continue
回复

使用道具 举报

千问 | 2010-3-1 11:19:06 | 显示全部楼层
不需要break啊,直接exit就行了,11g貌似没有break
回复

使用道具 举报

千问 | 2010-3-1 11:19:06 | 显示全部楼层
应该是只有continue
http://beyondrelational.com/modu ... cle-11gs-plsql.aspx
CONTINUE-WHEN statement
Syntax
view sourceprint?1.Continue-When(Condition)
Once the condition in the When clause is evaluated and if found true, the current iteration of the loop completes and control passes to the next iteration.
Let us see into action
view sourceprint?01.SQL> BEGIN
02.
2 FOR i IN 1 .. 10 LOOP
03.
3CONTINUE WHEN MOD(i,2) = 0;
04.
4 DBMS_OUTPUT.PUT_LINE('Numbers := ' || TO_CHAR(i));
05.
5 END LOOP;
06.
6END;
07.
7/
08.Numbers := 1
09.Numbers := 3
10.Numbers := 5
11.Numbers := 7
12.Numbers := 9
13.PL/SQL procedure successfully completed.
We can figure out that the even numbers trigger the control to the beginning of the loop.
The CONTINUE-WHEN statement can also be used with LOOP LABELS as shown under
view sourceprint?01.SQL> BEGIN
02.
2 >
03.
3 FOR i IN 1 .. 10 LOOP
04.
4CONTINUE outer_loop WHEN MOD(i,2) = 0;
05.
5DBMS_OUTPUT.PUT_LINE('Numbers := ' || TO_CHAR(i));
06.
6 END LOOP;
07.
7END;
08.
8/
09.Numbers := 1
10.Numbers := 3
11.Numbers := 5
12.Numbers := 7
13.Numbers := 9
14.PL/SQL procedure successfully completed.
We have the Continue statement in Sql Server too about which u can read from
SQL SERVER – Simple Example of WHILE Loop with BREAK and CONTINUE
SQL SERVER – Simple Example of WHILE Loop With CONTINUE and BREAK Keywords

回复

使用道具 举报

千问 | 2010-3-1 11:19:06 | 显示全部楼层
看楼主意思是要EXIT, 这个早就有了。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行