The previous triggers on t_series_ser raises problem to update coordinates, however, it would be great to have trigger that ensure that ser_x,ser_y and geom are always synchronised. With the following block, geom is computed from ser_x and ser_y at insert. Then, if we update either ser_x or ser_y, geom is automatically updated. Conversely, if we update geom, ser_x and ser_y are updated.
`create trigger update_geom after
insert or update of ser_x,ser_y on
datawg.t_series_ser for each row execute procedure datawg.update_geom();
CREATE OR REPLACE FUNCTION datawg.update_coordinates()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
BEGIN
NEW.ser_x = st_x(geom);
NEW.ser_y = st_y(geom);
RETURN NEW;
END;
$function$
;
create trigger update_coordinates after
update of geom on
datawg.t_series_ser for each row execute procedure datawg.update_coordinates();
`
The previous triggers on t_series_ser raises problem to update coordinates, however, it would be great to have trigger that ensure that ser_x,ser_y and geom are always synchronised. With the following block, geom is computed from ser_x and ser_y at insert. Then, if we update either ser_x or ser_y, geom is automatically updated. Conversely, if we update geom, ser_x and ser_y are updated.
`create trigger update_geom after insert or update of ser_x,ser_y on datawg.t_series_ser for each row execute procedure datawg.update_geom();
CREATE OR REPLACE FUNCTION datawg.update_coordinates() RETURNS trigger LANGUAGE plpgsql AS $function$ BEGIN NEW.ser_x = st_x(geom); NEW.ser_y = st_y(geom); RETURN NEW; END; $function$ ;
create trigger update_coordinates after update of geom on datawg.t_series_ser for each row execute procedure datawg.update_coordinates(); `