我在Postgresql 9.3中有2个功能:
CREATE OR REPLACE FUNCTION Function_A(param_id integer, param_name text)
RETURNS void AS
$BODY$
DECLARE
my_id integer;
my_name text;
BEGIN
my_id = somefunction(param_id);
my_name = somefunction(param_name);
insert into tableA(id, name) values (my_id, my_name);
END
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION Function_A(integer, text)
OWNER TO postgres;
CREATE OR REPLACE FUNCTION Function_B(param_id bigint, param_name text)
RETURNS void AS
$BODY$
DECLARE
BEGIN
insert into tableC(id, name) values (param_id, param_name);
perform Function_A(param_id, param_name);
END
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION Function_B(bigint, text)
OWNER TO postgres;
所以,我有问题,当函数A返回错误时,函数B不会在表C中插入数据。
我想要这样的东西:
如果执行功能A接下来返回错误,那么我的功能B可以将数据插入表C并继续进行而不会出现问题。
这可能吗?