Return boolean value from oracle function(从 oracle 函数返回布尔值)
问题描述
试图从函数返回值
create or replace function compairenumber(num1 in number,num2 in number)
return boolean is
begin
if num1 < num2 then
return true;
else
return false;
end if;
end;
当我提出问题时从对偶中选择compairenumber(5,10)它不返回真或假.
when i'm giving query select compairenumber(5,10) from dual its not returning true or false.
推荐答案
布尔值只能在其他PL/SQL代码中使用,不能在Oracle SQL中使用.如果你想要一个函数,它的返回值在 select ... from dual
中可用,那么你需要定义函数以返回 varchar2
和返回值 'true'
和 'false'
分别(或 'T'
和 'F'
,或返回数字,带有值1 和 0).
Boolean values can only be used in other PL/SQL code, not in Oracle SQL. If you want a function whose return value is available in a select ... from dual
then you will need to define the function to return varchar2
with the return values 'true'
and 'false'
respectively (or 'T'
and 'F'
, or return number, with the values 1 and 0).
令人遗憾的是,Oracle SQL 不支持布尔数据类型(尽管编程语言 PL/SQL 支持).
As sad as this is, Oracle SQL does not support the Boolean data type (although the programming language PL/SQL does).
这篇关于从 oracle 函数返回布尔值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 oracle 函数返回布尔值


基础教程推荐
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01