lightdb 创建函数或存储过程参数类型是date时兼容oracle的date类型
背景
在业务产品中,存在 oracle 移植过来的 sql 语句。它们在创建存储过程或函数时使用date类型。在使用时传入oracle的date类型。lightdb 24.1 版本对此进行了支持。
支持的语法场景
- CREATE 函数或存储过程
- DROP 函数或存储过程
- ALTER 函数或存储过程
- 支持包里的函数或存储过程
- COMMENT ON 函数或存储过程
- GRANT 函数或存储过程
- REVOKE 函数或存储过程
- SECURITY LABEL 函数或存储过程
包使用示例
create or replace package pack is
procedure ptest(x date);
function ftest(x date) return date;
end;
/
create or replace package body pack is
procedure ptest(x date) as
tmp varchar(20);
begin
tmp := 'hello world';
DBMS_OUTPUT.PUT_LINE('tmp: ' || tmp);
end;
function ftest(x date) return date as
tmp varchar(20);
begin
tmp := 'hello world';
DBMS_OUTPUT.PUT_LINE('tmp: ' || tmp);
return x;
end;
end;
/
\df pack.ptest
\df pack.ftest
call pack.ptest(sysdate);
select pack.ftest(sysdate);
执行结果

存储过程使用示例
create or replace procedure ptest(x date) AS
begin
DBMS_OUTPUT.PUT_LINE('tmp: ' || x);
end;
/
call ptest(sysdate);
执行结果

函数使用示例
create or replace function ftest(x date) return date AS
begin
DBMS_OUTPUT.PUT_LINE('tmp: ' || x);
return x;
end;
/
select ftest(sysdate);
执行结果

本文介绍了LightDB24.1版本对Oracle数据库中date类型的兼容性改进,包括创建、修改和调用存储过程和函数时,如何处理从Oracle移植过来的使用date类型的SQL语句,以及提供相关包和函数示例及执行结果。

1114

被折叠的 条评论
为什么被折叠?



