如何在SELECT语句中使用BOOLEAN类型 [英] How to use BOOLEAN type in SELECT statement

查看:456
本文介绍了如何在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.

这篇关于如何在SELECT语句中使用BOOLEAN类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆