powerbuilder 中执行postgresql存储过程

前端之家收集整理的这篇文章主要介绍了powerbuilder 中执行postgresql存储过程前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一、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获取

猜你在找的Postgre SQL相关文章