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 类型


基础教程推荐
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01