Partial rollback in function in postgres 9.6
Something like this:


DECLARE
  _exception_message text;
  _exception_hint text;
BEGIN 
    INSERT INTO table_a
    BEGIN
        INSERT INTO table_b
        RAISE EXCEPTION
        UPDATE table_b
        RETURN; 
    EXCEPTION
      WHEN OTHERS THEN
            GET STACKED DIAGNOSTICS _exception_message = MESSAGE_TEXT, _exception_hint = PG_EXCEPTION_HINT;
            RETURN; 
    END;
END


Reference: https://stackoverflow.com/questions/42638907/savepoint-in-postgresql-function