oracle 在 case 语句中返回一个布尔值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26971453/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Returning a boolean value in a case statement
提问by M.K.
I am trying to return a boolean value from a case statement but the compiler is complaining about a ORA-00936: missing expression error:
我试图从 case 语句返回一个布尔值,但编译器抱怨 ORA-00936: missing expression 错误:
SELECT
CASE MYCOLUMN
WHEN NULL THEN true
ELSE
false
END,
FROM MYTABLE;
I also tried the following but it doesn't work:
我也尝试了以下但它不起作用:
SELECT
CASE MYCOLUMN
WHEN NULL THEN SELECT true
ELSE
SELECT false
END,
FROM MYTABLE;
Is it possible to do this?
是否有可能做到这一点?
回答by juergen d
You need the IS
operator for NULL
checks
您需要IS
操作员进行NULL
检查
SELECT CASE WHEN MYCOLUMN IS NULL
THEN 1
ELSE 0
END
FROM MYTABLE;
回答by Rusty
BOOLEAN
type is not supported in SQL. It is supported only in procedural PL/SQL
BOOLEAN
SQL 中不支持类型。它仅在过程 PL/SQL 中受支持