加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

powerbuilder 中执行postgresql存储过程

发布时间:2020-12-13 17:49:01 所属栏目:百科 来源:网络整理
导读:一、postgresql存储过程 如下 CREATE OR REPLACE FUNCTION dbo.up_tregist_insert(IN p_vehicleno character varying,IN p_rdate timestamp without time zone,OUT rd_seq bigint) RETURNS bigint AS $BODY$ BEGIN INSERT INTO dbo.tregist(vehicleno,rdate)

一、postgresql存储过程 如下

CREATE OR REPLACE FUNCTION dbo.up_tregist_insert(IN p_vehicleno character varying,IN p_rdate timestamp without time zone,OUT rd_seq bigint)
RETURNS bigint AS
$BODY$


BEGIN
INSERT INTO dbo.tregist(vehicleno,rdate) VALUES (p_vehicleno,p_rdate);
SELECT currval('dbo.tregist_rd_seq')
into rd_seq
from dbo.tRegist
limit 1;
RETURN ;
EXCEPTION WHEN unique_violation THEN
-- Do nothing,and loop to try the UPDATE again.
END;$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION dbo.up_tregist_insert(character varying,timestamp without time zone)
OWNER TO postgres;


二、PB 代码如下

////插入到tRegist表 并返回RD值

declare regist_in procedure for up_tregist_insert(
:vehicleno,
:rdate ) using sqlca;
execute regist_in;
if sqlca.SqlCode <> 0 then
close regist_in;
rollback;
return
end if
fetch regist_in into :il_rd;
close regist_in;

commit;


三、注释

pb中声明存储过和时,只声明输入参数即可,输出参数通过fetch获取

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读