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 来判断的,


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM