oracle中if else的三種實現方式詳解

2022-09-21 10:12:11 字數 770 閱讀 8989

1、標準sql規範

1、單個if

程式設計客棧if v=... then

end if;

2、if ... else

if v=... then

else

t....;

end if;

3、多個if 

if v=... then

elsif v=... then程式設計客棧

t...;

end ifl

注意: 多個if的是'elsif' 不是 ' else if'

2、decode函式

decode(value,if1,then1,if2,then2,if2

表示如果valu程式設計客棧e等於if1時,decode函式的結果返回then1,...,如果不等於任何乙個if值,則返回else。

3、case when

case where v=... then 'vvvvv';

where v=... then 'ffff';

else

.....;

end as '別名';

注意點:

1、以case開頭,以end結尾

2、分支中when 後跟條件,then為顯示結果

3、else  為除此之外的預設情況,類似於高階語言程式中switch case的default,可以www.cppcns.com不加

4、end 後跟別名 

總結本文標題: oracle中if/else的三種實現方式詳解

本文位址:

oracle中if else的三種實現方式

1 標準sql規範 1 單個if if v then endif 2 if else if v then else t.endif 3 多個if if v then elsif v then t.endifl 注意 多個if的是 elsif 不是 else if 2 decode函式 decode ...

oracle中if else功能的實現

一 單個if 1 if a then end if 2 if a then else end if 二 多個if if a then elsif a then end if 這裡中間是 elsif 而不是else if 這裡需要特別注意 2 decode函式 decode的語法 decode val...

oracle中if else的3種寫法

1 標準sql規範 1 一 單個if 21 34 if a then 5.6endif 782 910 if a then 11.12else 13.14endif 1516 二 多個if 1718 if a then 19.20 elsif a then 21.22end if 23 這裡中間是 ...