首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

(转)Oraclepl/sql中实现continue的步骤

2013-10-28 
(转)Oraclepl/sql中实现continue的方法3611人阅读?评论(0)?CREATE?TABLE?AREAS(??RADIUS??NUMBER(5),??ARE

(转)Oraclepl/sql中实现continue的方法
3611人阅读?评论(0)?CREATE?TABLE?AREAS
(转)Oraclepl/sql中实现continue的步骤(
(转)Oraclepl/sql中实现continue的步骤??RADIUS??NUMBER(5),
(转)Oraclepl/sql中实现continue的步骤??AREA????NUMBER(14,2)
(转)Oraclepl/sql中实现continue的步骤);

方法一:使用 goto

(转)Oraclepl/sql中实现continue的步骤DECLARE
(转)Oraclepl/sql中实现continue的步骤???pi???CONSTANT?NUMBER?(9,?7)??:=?3.1415927;
(转)Oraclepl/sql中实现continue的步骤???radius????????INTEGER?(5);
(转)Oraclepl/sql中实现continue的步骤???area??????????NUMBER?(14,?2);
(转)Oraclepl/sql中实现continue的步骤BEGIN
(转)Oraclepl/sql中实现continue的步骤???radius?:=?0;
(转)Oraclepl/sql中实现continue的步骤
(转)Oraclepl/sql中实现continue的步骤???LOOP
(转)Oraclepl/sql中实现continue的步骤
(转)Oraclepl/sql中实现continue的步骤??????<<here>>
(转)Oraclepl/sql中实现continue的步骤??????radius?:=?radius?+?1;
(转)Oraclepl/sql中实现continue的步骤
(转)Oraclepl/sql中实现continue的步骤??????IF?radius?=?4
(转)Oraclepl/sql中实现continue的步骤??????THEN
(转)Oraclepl/sql中实现continue的步骤?????????GOTO?here;
(转)Oraclepl/sql中实现continue的步骤??????ELSE
(转)Oraclepl/sql中实现continue的步骤?????????area?:=?pi?*?POWER?(radius,?2);
(转)Oraclepl/sql中实现continue的步骤
(转)Oraclepl/sql中实现continue的步骤?????????INSERT?INTO?areas
(转)Oraclepl/sql中实现continue的步骤??????????????VALUES?(radius,?area);
(转)Oraclepl/sql中实现continue的步骤
(转)Oraclepl/sql中实现continue的步骤?????????EXIT?WHEN?area?>?100;
(转)Oraclepl/sql中实现continue的步骤??????END?IF;
(转)Oraclepl/sql中实现continue的步骤???END?LOOP;
(转)Oraclepl/sql中实现continue的步骤
(转)Oraclepl/sql中实现continue的步骤???COMMIT;
(转)Oraclepl/sql中实现continue的步骤EXCEPTION
(转)Oraclepl/sql中实现continue的步骤???WHEN?OTHERS
(转)Oraclepl/sql中实现continue的步骤???THEN
(转)Oraclepl/sql中实现continue的步骤??????ROLLBACK;
(转)Oraclepl/sql中实现continue的步骤??????RAISE;
(转)Oraclepl/sql中实现continue的步骤END;

?-- 方法二:使用 exception

(转)Oraclepl/sql中实现continue的步骤--?利用系统?exception
(转)Oraclepl/sql中实现continue的步骤DECLARE
(转)Oraclepl/sql中实现continue的步骤???pi?????CONSTANT?NUMBER?(9,?7)??:=?3.1415927;
(转)Oraclepl/sql中实现continue的步骤???radius??????????INTEGER?(5);
(转)Oraclepl/sql中实现continue的步骤???area????????????NUMBER?(14,?2);
(转)Oraclepl/sql中实现continue的步骤???some_variable???NUMBER?(14,?2);
(转)Oraclepl/sql中实现continue的步骤BEGIN
(转)Oraclepl/sql中实现continue的步骤???radius?:=?0;
(转)Oraclepl/sql中实现continue的步骤
(转)Oraclepl/sql中实现continue的步骤???LOOP
(转)Oraclepl/sql中实现continue的步骤??????BEGIN
(转)Oraclepl/sql中实现continue的步骤?????????radius?:=?radius?+?1;
(转)Oraclepl/sql中实现continue的步骤?????????some_variable?:=?1?/?(radius?-?4);
(转)Oraclepl/sql中实现continue的步骤?????????area?:=?pi?*?POWER?(radius,?2);
(转)Oraclepl/sql中实现continue的步骤
(转)Oraclepl/sql中实现continue的步骤?????????INSERT?INTO?areas
(转)Oraclepl/sql中实现continue的步骤??????????????VALUES?(radius,?area);
(转)Oraclepl/sql中实现continue的步骤
(转)Oraclepl/sql中实现continue的步骤?????????EXIT?WHEN?area?>?100;
(转)Oraclepl/sql中实现continue的步骤??????EXCEPTION
(转)Oraclepl/sql中实现continue的步骤?????????WHEN?ZERO_DIVIDE
(转)Oraclepl/sql中实现continue的步骤?????????THEN
(转)Oraclepl/sql中实现continue的步骤????????????NULL;
(转)Oraclepl/sql中实现continue的步骤??????END;
(转)Oraclepl/sql中实现continue的步骤???END?LOOP;
(转)Oraclepl/sql中实现continue的步骤
(转)Oraclepl/sql中实现continue的步骤???COMMIT;
(转)Oraclepl/sql中实现continue的步骤EXCEPTION
(转)Oraclepl/sql中实现continue的步骤???WHEN?OTHERS
(转)Oraclepl/sql中实现continue的步骤???THEN
(转)Oraclepl/sql中实现continue的步骤??????ROLLBACK;
(转)Oraclepl/sql中实现continue的步骤??????RAISE;
(转)Oraclepl/sql中实现continue的步骤END;

?

(转)Oraclepl/sql中实现continue的步骤--?自定义?exception
(转)Oraclepl/sql中实现continue的步骤DECLARE
(转)Oraclepl/sql中实现continue的步骤???pi??????????????CONSTANT?NUMBER?(9,?7)??:=?3.1415927;
(转)Oraclepl/sql中实现continue的步骤???radius???????????????????INTEGER?(5);
(转)Oraclepl/sql中实现continue的步骤???area?????????????????????NUMBER?(14,?2);
(转)Oraclepl/sql中实现continue的步骤???e_userdefinedexception???EXCEPTION;
(转)Oraclepl/sql中实现continue的步骤???PRAGMA?EXCEPTION_INIT?(e_userdefinedexception,?-1401);
(转)Oraclepl/sql中实现continue的步骤BEGIN
(转)Oraclepl/sql中实现continue的步骤???radius?:=?0;
(转)Oraclepl/sql中实现continue的步骤
(转)Oraclepl/sql中实现continue的步骤???LOOP
(转)Oraclepl/sql中实现continue的步骤??????radius?:=?radius?+?1;
(转)Oraclepl/sql中实现continue的步骤
(转)Oraclepl/sql中实现continue的步骤??????BEGIN
(转)Oraclepl/sql中实现continue的步骤?????????IF?radius?=?4
(转)Oraclepl/sql中实现continue的步骤?????????THEN
(转)Oraclepl/sql中实现continue的步骤????????????RAISE?e_userdefinedexception;
(转)Oraclepl/sql中实现continue的步骤?????????ELSE
(转)Oraclepl/sql中实现continue的步骤????????????area?:=?pi?*?POWER?(radius,?2);
(转)Oraclepl/sql中实现continue的步骤
(转)Oraclepl/sql中实现continue的步骤????????????INSERT?INTO?areas
(转)Oraclepl/sql中实现continue的步骤?????????????????VALUES?(radius,?area);
(转)Oraclepl/sql中实现continue的步骤
(转)Oraclepl/sql中实现continue的步骤????????????EXIT?WHEN?area?>?100;
(转)Oraclepl/sql中实现continue的步骤?????????END?IF;
(转)Oraclepl/sql中实现continue的步骤??????EXCEPTION
(转)Oraclepl/sql中实现continue的步骤?????????WHEN?e_userdefinedexception
(转)Oraclepl/sql中实现continue的步骤?????????THEN
(转)Oraclepl/sql中实现continue的步骤????????????NULL;
(转)Oraclepl/sql中实现continue的步骤??????END;
(转)Oraclepl/sql中实现continue的步骤???END?LOOP;
(转)Oraclepl/sql中实现continue的步骤
(转)Oraclepl/sql中实现continue的步骤???COMMIT;
(转)Oraclepl/sql中实现continue的步骤EXCEPTION
(转)Oraclepl/sql中实现continue的步骤???WHEN?OTHERS
(转)Oraclepl/sql中实现continue的步骤???THEN
(转)Oraclepl/sql中实现continue的步骤??????ROLLBACK;
(转)Oraclepl/sql中实现continue的步骤??????RAISE;
(转)Oraclepl/sql中实现continue的步骤END;转自:http://www.itpub.net/thread-1118901-1-1.html如果CONTINUE只有一两处,而且可以轻易变成IF..ELSE.., 那么就用IF ELSE, 这也是TOM推荐的方法。
但有时候CONTINUE藏在其他复杂的控制结构里面,IF ELSE 就不容易搞定了。我会用这种方法:


FOR 或者 WHILE 主循环 LOOP
? ? FOR v_foo IN 1..1 LOOP? ???---- 第二层假循环

? ?? ???……代码……
? ?? ???IF …… THEN
? ?? ?? ???EXIT;? ?? ?---- 退出假循环,等效于CONTINUE主循环
? ?? ???END IF;
? ?? ???……代码……
? ?? ??
? ?? ???IF …… THEN?
? ?? ?? ???EXIT main_loop;? ? ---- 如果需要退出主循环,用这个写法
? ?? ???END IF;

? ?? ???……代码……

? ? END LOOP v_foo;??---- 第二层假循环结束
END LOOP main_loop; ---- 主循环结束

初看有些古怪,因为用EXIT代替了CONTINUE. 但习惯了就会发现很灵活。

热点排行