[Qgis-user] Defining action to update fields while editing?
Bernd Vogelgesang
bernd.vogelgesang at gmx.de
Mon Nov 12 03:00:41 PST 2012
> Here's some "witchcraft"
>
> In a spatialite DB, I have a polygon table "fields". I Added an integer
> column "val"
> and a column "result_val" of type real. Then I set up this trigger:
>
> CREATE TRIGGER update_result_trig
> AFTER UPDATE ON "fields"
> BEGIN
> UPDATE fields
> SET result_val=(val*ST_Area(geometry))
> WHERE ROWID=NEW.ROWID;
> END
>
> I loaded the spatialite polygon layer into QGIS and set the "result_val"
> attribute as a label for each polygon. Now I started editing. At each
> click of
> the save button the label, representing the result_val, changes. Seems
> to work
> nicely.
>
> HTH
> Micha
>
Thanks a lot, Micha!
Did not hurt at all :)
One little glitch maybe:
I first imported the shape into the spatialite db, then created the new
trigger according to your example and then loaded it into qgis.
Created a label for the calculated value.
Editing the polygon and saving returns the new values.
BUT, these values now seem to be real values with up to 13 digits
precision. The table manager plugin says, the field is still integer. How
is this possible to store real values in an integer field?!
Can someone show me the way to round the values or to tell spatialite to
respect the integer settings?
Further on the original question:
So, it seems there is no way to perform such actions from within qgis
directly, which is a pity.
It will be a very hard if not impossible mission to teach those people
into spatialite ... they are dinosaurs from the ArcView3.x-aeons.
Thanx for your answers
Bernd
--
Bernd Vogelgesang * Siedlerstrasse 2 * 91083 Baiersdorf * +49-9133-825374
More information about the Qgis-user
mailing list