存儲過程中的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 來判斷的,