随笔-124  评论-49  文章-56  trackbacks-0
--控制语句
--
if
if condition then 
  statements;
elsif condition 
then
  statements;
else
  statements;
end if;
--case
case v_no
when 10 then
  statements;
when 20 then
  statements;
when 30 then
  statements;
else
  statements;
end case;
--------------
case 
when v_no>30 then
  statements;
when v_no>20 then
  statements;
when v_no>10 then
  statements;
end case;
--loop
loop
  statements;
  
  
exit when condition;
end loop;
--while
while condition loop
  statements;
  
end loop;
--for
for i in [reverse]
v_start..v_end loop
  statements;
end loop;
--i是循环控制变量,不需要显式定义,v_start,v_end分别为下界值和上界值。如果指定reverse则循环变量自动减一。
begin
  
for i in reverse 1..10 loop
    dbms_output.put_line(i);
  
end loop;
end;
--10,9,8,7,6,5,4,3,2,1
--
嵌套循环
declare
  result 
int;
begin
    
<<outer>>
    
for i in 1..10 loop
      
<<inner>>
      
for j in 1..10 loop
        result:
=i*j;
        
exit outer when i=9;
        dbms_output.put_line(i
||j);
      
end loop inner;
    
end loop outer;
end;
posted on 2010-07-29 17:12 junly 阅读(325) 评论(0)  编辑  收藏 所属分类: oracle/mysql/sql

只有注册用户登录后才能发表评论。


网站导航: