Skip to content

Instantly share code, notes, and snippets.

@pigreco
Created January 9, 2018 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pigreco/e98cb9e3bea2002f4b344309d9967b1c to your computer and use it in GitHub Desktop.
Save pigreco/e98cb9e3bea2002f4b344309d9967b1c to your computer and use it in GitHub Desktop.
Trigger suggerito da Furieri che migliora notevolmente le prestazioni.
CREATE TRIGGER ins_punti AFTER INSERT ON punti
BEGIN
INSERT OR REPLACE INTO punti (pk_p, nome_strada, data_ins, distanza, geom)
SELECT NEW.ROWID, s.nome_strada, DateTime('now'), k.distance, NEW.geom
FROM knn AS k
LEFT JOIN strade AS s ON (k.fid = s.pk_l)
WHERE k.f_table_name = 'strade'
AND ref_geometry = NEW.geom
AND k.max_items = 1;
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment