如何在 SELECT 语句中使用 BOOLEAN 类型
我有一个参数为 BOOLEAN 的 PL/SQL 函数:
I have a PL/SQL function with BOOLEAN in parameter:
function get_something(name in varchar2, ignore_notfound in boolean);
此功能是第三方工具的一部分,我无法更改.
This function is a part of 3rd party tool, I cannot change this.
我想在像这样的 SELECT 语句中使用这个函数:
I would like to use this function inside a SELECT statement like this:
select get_something('NAME', TRUE) from dual;
这不起作用,我收到此异常:
This does not work, I get this exception:
ORA-00904:TRUE":无效标识符
ORA-00904: "TRUE": invalid identifier
据我所知,无法识别关键字 TRUE
.
As I understand it, keyword TRUE
is not recognized.
我怎样才能做到这一点?
How can I make this work?
推荐答案
你可以像这样构建一个包装函数:
You can build a wrapper function like this:
function get_something(name in varchar2,
ignore_notfound in varchar2) return varchar2
is
begin
return get_something (name, (upper(ignore_notfound) = 'TRUE') );
end;
然后调用:
select get_something('NAME', 'TRUE') from dual;
您的版本中 ignore_notfound 的有效值是什么取决于您,我假设TRUE"表示 TRUE,其他任何表示 FALSE.
It's up to you what the valid values of ignore_notfound are in your version, I have assumed 'TRUE' means TRUE and anything else means FALSE.
相关文章