一、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;
三、注释