lightdb 支持无参函数无括号使用

背景

在 Oracle 中,用户自定义的无参函数可以不带括号执行。为支持该特性,LightDB 24.1 版本中,允许用户使用无参函数的函数名调用函数,包括系统函数,如:now. 此功能限制在 LightDB 的 oracle 数据库下运行。

用例

create function fn_noparam RETURN int
as
begin
  return 1;
end;
/
--= 1, simple expr
select fn_noparam from dual;
--= 2
select fn_noparam + 1 from dual;
--= 1
select 1 from dual where fn_noparam = 1;

--= 1, composed expr
select least(fn_noparam, 2) from dual;

校验列名和函数名的优先级

create table t2(fn_noparam int, a int);
insert into t2 values(0, 1);
insert into t2 values(1, 1);

--= 1
select count(*) from t2 where fn_noparam = a;
--= 1
select count(*) from t2 where 1 + fn_noparam = a;

posted on 2024-01-22 11:29  winter-loo  阅读(9)  评论(0编辑  收藏  举报

导航