ITPub博客

首页 > 数据库 > Oracle > case语句中比较null

case语句中比较null

原创 Oracle 作者:warmbreeze 时间:2015-11-27 16:54:18 0 删除 编辑
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博客 ” ,链接:http://blog.itpub.net/37279/viewspace-1848087/,如需转载,请注明出处,否则将追究法律责任。

下一篇: trigger on clob
请登录后发表评论 登录
全部评论

注册时间:2012-02-15

  • 博文量
    45
  • 访问量
    42544