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