DB2——存储过程-条件判断语句if then

存储过程中的if then 语法

IF A > B THEN
...
ELSEIF A = B THEN
...
ELSE
...
END IF

举例来说

 if upper(v_lx) = 'V' then     
      if exists(select 1 from syscat.views where  viewschema='PAS' and viewname=ltrim(rtrim(replace(upper(v_ccmc),'PAS.','')))) then
        set v_sql='drop view '||v_ccmc;
        prepare s1 from v_sql;
        execute s1;
      end if;   到这里是一个if,if exists这个if,外面的If包含了里面的if
    end if;

执行顺序: 判断v_lx 变为大写后是不是'V' 是的话进行判断下一个if判断,不是的话什么也不做,我们区分是不是同一个if的话也是用end if 来判断的,

猜你喜欢

转载自www.cnblogs.com/wy20110919/p/9051367.html