1

I use this trigger on a geopackage table:

CREATE TRIGGER upd_iae_surf AFTER UPDATE ON "IAE CRD Surf" 
BEGIN 
UPDATE "IAE CRD Surf" SET 
"taille" = ROUND(ST_Area(NEW.geom)/10000,3)
WHERE fid = NEW.fid; 
END

When I modify this table in QGIS, I've got this message:
Erreur OGR lors du paramétrage de l'entité 2802 : failed to execute update : too many levels of trigger recursion.
I don't find any problem in my trigger. What is the problem ?

2 Answers 2

0

Read https://github.com/qgis/QGIS/issues/52346 and try if this works also for you:

CREATE TRIGGER upd_iae_surf AFTER UPDATE of dummy ON "IAE CRD Surf" 
BEGIN 
UPDATE "IAE CRD Surf" SET 
"taille" = ROUND(ST_Area(NEW.geom)/10000,3)
WHERE fid = NEW.fid; 
END
1
  • Ok, it works for AFTER UPDATE, but how to solve the same problem with AFTER INSERT ?
    – Etienne
    Commented Oct 27, 2023 at 13:16
0

Your trigger reads:

When table "IAE CRD Surf" is updated then update field "taille" = ROUND(ST_Area(NEW.geom)/10000,3).

This means that when the trigger runs, the trigger will run again because it is updated again.

Probably want:

CREATE TRIGGER upd_iae_surf AFTER INSERT
ON "IAE CRD Surf" 
BEGIN 
UPDATE "IAE CRD Surf" SET 
"taille" = ROUND(ST_Area(NEW.geom)/10000,3)
WHERE fid = NEW.fid; 
END

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.