I have two tables, A and B. B is a backup of A.
Table A has a trigger:
CREATE OR REPLACE TRIGGER trigger
AFTER INSERT OR UPDATE OR DELETE
ON A
FOR EACH ROW
EXECUTE FUNCTION trigger_function();
And the trigger function:
INSERT INTO B (
id,
geom
)
VALUES (
OLD.id,
OLD.geom
);
return null;
Tables A and B have full rights, both have a primary key (id for A and B has its own).
My idea is that this will fill table B with the points made/changed in table A, and those points can be kept as a backup. This works for for all fields I try except geom, for some reason geom can't be written to B by the trigger. I have populated B with points without issue through FME and can work with them fine in QGIS, so the issue (I assume) must be with my trigger setup or pgAdmin.
Any clues as to why geom can't be transferred?
INSERT OR UPDATE OR DELETE
- not a good idea. Can you show the definitions for your tables "A" and "B"? Perhaps the problem is in the primary key sequence. It is better to store the OLD.id without unique constraint in a separate “previous_id” field.