case语句有两种:Simple CASE和Searched CASE
Searched CASE可以用来比较null
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE 11.2.0.4.0 Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
SQL> select case when null is null then 'is null' else 'not is null' end as case_result from dual ;
CASE_RESULT
----------------------
is null
也可以用绑定变量
SQL> variable i varchar2
SQL> exec :i := NULL;
select case when :i is null then 'is null' else 'not is null' end as case_result from dual ;
PL/SQL procedure successfully completed.
SQL>
CASE_RESULT
----------------------
is null
1 row selected.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/37279/viewspace-1848087/
,如需转载,请注明出处,否则将追究法律责任。