当前位置: 移动技术网 > IT编程>数据库>其他数据库 > MySQL与Oracle 差异比较之四条件循环语句

MySQL与Oracle 差异比较之四条件循环语句

2017年12月01日  | 移动技术网IT编程  | 我要评论
循环语句 编号 类别 oracle mysql 注释

循环语句

编号 类别 oracle mysql 注释
1 if语句使用不同 if iv_weekly_day = 'mon'then
       ii_weekly_day := 'mon';
elsif iv_weekly_day = 'tue' then
       ii_weekly_day := 'tue';
end if;
if iv_weekly_day = 'mon'then
      set ii_weekly_day = 'mon';
elseif iv_weekly_day = 'tue' then
      set ii_weekly_day = 'tue';
end if;  
1. mysql和oracle除了关键字有一个字差别外(elseif/elsif),if语句使用起来完全相同. 
2. mysql if语句语法: 摘自 mysql 5.1 参考手册 20.2.12.1. if语句 
if search_condition then statement_list
    [elseif search_condition then statement_list] ...
    [else statement_list]
end if
if实现了一个基本的条件构造。如果search_condition求值为真,相应的sql语句列表被执行。如果没有search_condition匹配,在else子句里的语句列表被执行。statement_list可以包括一个或多个语句。
2 for语句不同 for li_cnt in 0..(ii_role_cnt-1) loop
    select count(*) into li_role_ik_cnt from sd_role
    where role_cd = lo_aas_role_upl(li_cnt);
    if li_role_ik_cnt = 0  then
        return 'n';
    end if;
    li_role_ik_cnt := -3;
end loop; 
looplable:loop
  if i > (ii_role_cnt-1) then
    leave looplable;
  else
    select count(*) into li_role_ik_cnt from sd_role
    where role_cd = 'admin_super'; /*lo_aas_role_upl(li_cnt);*/
    if li_role_ik_cnt = 0  then
       return 'n';
    end if;
    set li_role_ik_cnt = -3;
    set i = i+1;
   end if;
 end loop looplable;

1. oracle使用for语句实现循环. 
   mysql使用loop语句实现循环. 
2. oracle 使用for…loop关键字. 
   mysql使用looplable:loop实现循环. 
3 while语句不同 while lv_inputstr is not null loop
...
end loop;
while lv_inputstr is not null do
...
end while;
1. oracle 中使用while语句关键字为: while 表达式 loop… end loop;
    mysql 中使用while语句关键字为: while 表达式 do… end while;

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网