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 类型
基础教程推荐
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- 无法解决整理冲突 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
