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   winter-loo  阅读(13)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示