How to use BOOLEAN type in SELECT statement(如何在 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 类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 SELECT 语句中使用 BOOLEAN 类型


- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- SQL 临时表问题 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01