root@modb:~# su - omm
omm@modb:~$ gsql -r
gsql ((openGauss 2.0.0 build 78689da9) compiled at 2021-03-31 21:03:52 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
omm=# create function test123(num1 in integer,num2 in integer,num3 out integer) return integer
omm-# as
omm$# beginomm$#
num3 := num1 + num2;
omm$# end;
omm$# /
CREATE FUNCTION
omm=# call test123(1,2,3);
num3
------
3
(1 row)
omm=# call test123(2,3,4);
num3
------
5
(1 row)
omm=# call test123(num1 := 3,num2 :=44,3);
num3
------
47
(1 row)
omm=# create function test456(i int out result_1 bigint,out result_2 bigint)
omm-# returns setof record
omm-# as $$
omm$# begin
omm$# result_1 = i+1;
omm$# result_2 i * 10;
omm$# return next;omm$#
end;
omm$# $$language plpgsql;
ERROR: syntax error at or near "out"
LINE 1: create function test456(i int out result_1 bigint,out result...
^
omm=# CREATE OR REPLACE FUNCTION test456(i int, out result_1 bigint, out result_2
omm(# bigint)
omm-# returns SETOF RECORD
omm-# as $$
omm$# begin
omm$# result_1 = i + 1;
omm$# result_2 = i * 10;
omm$# omm$# end;
return next;
omm$# $$language plpgsql;
CREATE FUNCTION
omm=# call test456(1, 0, 0);
result_1 | result_2
----------+----------
2 | 10
(1 row)
omm=# \sf test456
CREATE OR REPLACE FUNCTION public.test456(i integer, OUT result_1 bigint, OUT result_2 bigint)
RETURNS SETOF record
LANGUAGE plpgsql
NOT FENCED NOT SHIPPABLE
AS $function$
begin
result_1 = i + 1;
result_2 = i * 10;
return next;
end;
$function$;
omm=# alter function test123(integer,integer) rename to test123_new;
ALTER FUNCTION
omm=# \sf test123_new
CREATE OR REPLACE FUNCTION public.test123_new(num1 integer, num2 integer, OUT num3 integer)
RETURNS integer
LANGUAGE plpgsql
NOT FENCED NOT SHIPPABLE
AS $function$ DECLARE
begin
num3 := num1 + num2;
end$function$;
omm=# drop function test123_new;
omm=# DROP FUNCTION
omm=# drop function test456;
DROP FUNCTION
omm=# \sf
function name is required
omm=#
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
2025年3月国产数据库大事记
墨天轮编辑部
956次阅读
2025-04-03 15:21:16
MogDB 发布更新,解决 openGauss 数据库在长事务情况下Ustore表膨胀问题
MogDB
293次阅读
2025-04-17 10:41:41
MogDB 发布更新,解决 openGauss 数据库在长事务情况下Ustore表膨胀问题
云和恩墨
194次阅读
2025-04-16 09:52:02
GitCode 成 openGauss 新归宿,国产开源数据库里程碑事件
严少安
147次阅读
2025-04-27 11:37:53
荣誉时刻!openGauss认证证书快递已发,快来看看谁榜上有名!
墨天轮小教习
129次阅读
2025-04-23 17:39:13
openGauss荣获中国软件行业协会多奖项,技术升级再创行业新高度
openGauss
123次阅读
2025-04-30 14:30:58
单个执行机并行执行MySQL到openGauss数据迁移子任务
Clipnosis
114次阅读
2025-04-30 16:39:58
openGauss6.0.0适配操作系统自带的软件,不依赖三方库
来杯拿铁
84次阅读
2025-04-18 10:49:53
opengauss使用gs_probackup进行增量备份恢复
进击的CJR
75次阅读
2025-04-09 16:11:58
Postgresql数据库单个Page最多存储多少行数据
maozicb
68次阅读
2025-04-23 16:02:19