案例表达式和布尔值

Case expressions and boolean

为什么只有第一个有效?

  1. returns 'blue':

    select case when 'a' = 'a' then 'blue' end from dual;

  2. 错误:ORA-00920:无效的关系运算符

    select case when true then 'blue' end from dual;

  3. ORA-00904: "TRUE": 标识符无效

    select case when 'a' = 'a' then true end from dual;

  4. ORA-00905: 缺少关键字

    select case when 'b' = 'b' then 'a' = 'a' end from dual;

Oracle SQL 中没有真正的布尔 sql 类型。既不是 True 也不是 False 常量。布尔值通常由单个字符 'Y' 或 'N' 或数字 0 或 1 表示。