Created
December 16, 2017 21:38
-
-
Save pigreco/edce696e5bd91fded166b9c601baf717 to your computer and use it in GitHub Desktop.
esempio di trigger per il calcolo lunghezza linea dopo inserimento o modifica geometria
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE stradario | |
(pk INTEGER PRIMARY KEY autoincrement NOT NULL, | |
nome TEXT, | |
lunghezza DOUBLE, | |
note TEXT); | |
SELECT AddGeometryColumn('stradario','geom',32632,'LINESTRING',2); | |
CREATE TRIGGER insert_calc_length AFTER INSERT ON stradario -- calcola lunghezza dopo inserimento strada | |
BEGIN | |
UPDATE stradario | |
SET | |
lunghezza= ST_LENGTH(geom) | |
WHERE ROWID=NEW.ROWID; | |
END | |
CREATE TRIGGER update_calc_length AFTER UPDATE OF geom ON stradario -- aggiorna lunghezza dopo modifica strada | |
BEGIN | |
UPDATE stradario | |
SET | |
lunghezza= ST_LENGTH(geom) | |
WHERE ROWID=NEW.ROWID; | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment