Reputation: 1
I have 2 functions in Postgresql 9.3:
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;
So, I have problem, when Function A returns error, Function B does not insert data into table C.
I want something like this:
If Perform Function A returns error resume next, so my Function B can insert data into table C and continue without problem.
Is this possible?
Upvotes: 0
Views: 203
Reputation: 129
Without the actual SQL code, we cannot actually help you that much. If you want to force a function to continue without caring about errors, then you can use SQL exception syntax
EXCEPTION WHEN OTHERS THEN
-- keep looping
END;
Upvotes: 1