Du kan skrive en BEFORE
trigger:
CREATE FUNCTION id_trigger() RETURNS trigger
LANGUAGE plpgsql AS
$$BEGIN
NEW.id = nextval(pg_get_serial_sequence(TG_ARGV[0], 'id'));
RETURN NEW;
END;$$;
CREATE TRIGGER id_trigger BEFORE INSERT ON qs_facts_template
FOR EACH ROW EXECUTE PROCEDURE id_trigger('qs_facts_template');