怎么在阿里云建网站,免费seo网站优化,网站首页布局设计工具,安阳河南网站建设LightDB 函数/存储过程支持在任意位置使用默认值
在之前的版本中#xff0c;在 LightDB 中创建的函数或存储过程#xff0c;每个有默认值的参数后面的参数都需要有默认值#xff08;同c中函数, 默认值从右向左赋值#xff09;。 在 24.1 版本中支持oracle 中的默认值用法在 LightDB 中创建的函数或存储过程每个有默认值的参数后面的参数都需要有默认值同c中函数, 默认值从右向左赋值。 在 24.1 版本中支持oracle 中的默认值用法有默认值的参数后面的参数可以没有默认值。
示例
在有默认值的参数后面的参数没有默认值情况下在pg_proc 对于没有默认值的参数会有 null 的默认值 实际不会使用对于这种参数仍需传入参数函数才能使用 。可以结合lt_proc_ext 的procconfig字段默认值对应的参数id 为-1则表示为伪默认值不会实际使用。
lightdbpostgres# create database test_o with lightdb_syntax_compatible_type oracle;
NOTICE: role test_o already exists
CREATE DATABASE
lightdbpostgres# \c test_o
You are now connected to database test_o as user lightdb.
compatible type: oraclecreate function testfd
(a1 int,a2 varchar default 2,a3 varchar,a4 int default 14
)
return varchar as
beginreturn a1 || || a2 || || a3 || || a4;
end;
/lightdbtest_o# select proname, proaccess, procconfig from lt_proc_ext where proname testfd order by oid;proname | proaccess | procconfig
--------------------------------------------------------------------------------testfd | n | {PROCCONFIG :argDefaultCount 3 :argDefaultIndexes 1 -1 3}
(1 row)lightdbtest_o# select pg_get_expr(proargdefaults,0) from pg_proc where proname testfd;pg_get_expr
-----------------------------------------------------2::character varying, NULL::character varying, 14
(1 row)lightdbtest_o#
lightdbtest_o# select testfd(a11, a3q);testfd
----------------1 2 q 14
(1 row)lightdbtest_o# select testfd(1, 2, 3);testfd
----------------1 2 3 14
(1 row)lightdbtest_o# select testfd(1);
ERROR: function testfd(integer) does not exist
LINE 1: select testfd(1);^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
lightdbtest_o#