QGIS 3.x

Geopackage Triggers

CREATE TRIGGER update_esn AFTER INSERT
ON addresses
BEGIN
update addresspoints set esn = (select esn from polygon where st_within(new.geom, geom));
END;

Calculo de área automático em Spatialite e Virtual Layers no QGIS

CREATE TRIGGER 'calcula_area_alterada' AFTER UPDATE ON "plantio" 
FOR EACH ROW BEGIN 
    UPDATE "plantio" SET "area" = st_area(NEW."geom")/10000 
    WHERE "pkuid" = NEW."pkuid"; 
END;

CREATE TRIGGER 'calcula_area_alterada' AFTER UPDATE ON "plantio" 
FOR EACH ROW 
    BEGIN UPDATE "plantio" SET "area" = st_area(NEW."geom")/10000 
    WHERE "pkuid" = NEW."pkuid";
END;

Referências

Avatar
Sidney Schaberle Goveia
Sidney S. Goveia

Especialista em SIG (desde 1998)