I want to record an insert or update events happening on one spatial table into another table (non spatial) for simple historical purpose.
Say for example I have 2 tables SpatialA (date1 DATE, guid VARCHAR38, objectid INT, col1 VARCHAR5 ,shape) and NonSpatialB (date1 DATE, guid VARCHAR38, objectid INT, col1 VARCHAR5).
I have trigger on SpatialA table that executes function :
CREATE OR REPLACE FUNCTION function_copy() RETURNS TRIGGER AS
$BODY$
BEGIN
INSERT INTO
schema1.NonSpatialB (date1 ,*objectid*) //schema1.NonSpatialB (date1 ,*GUID*) --> I also tried using "GUID" as well
VALUES(new.date1,new.objectid);
RETURN new;
END;
$BODY$
language plpgsql;
CREATE TRIGGER trig_copy
AFTER INSERT ON schema1.SpatialA
FOR EACH ROW
EXECUTE PROCEDURE function_copy();
The data on SpatialA are updated via Survey123 or FieldMap.
When the trigger is enabled, I CANNOT insert nor update a record on SpatialA. The trigger prevents the update or insert event from happening.
How do I suppose to write the function so that I can insert into another table?
Note: those trigger and function work perfectly when I do insert or update on non spatial table
I am using Postgresql13, Arcgis Enterprise 11.0