powerbuilder 中执行postgresql存储过程

来源:互联网 发布:读取图片文字软件 编辑:程序博客网 时间:2024/06/05 12:58

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

原创粉丝点击