MANUELA Wiki
Tool for assessment of environmental services on farm scale.
Status: Beta
Brought to you by:
wellgis
PL-SQL |
---------- |
CREATE OR REPLACE FUNCTION move_ground_points() RETURNS void AS
$BODY$
DECLARE
r INTEGER;
BEGIN
FOR r IN
SELECT DISTINCT request_year
FROM invekos
LOOP
RAISE NOTICE '%', r;
UPDATE soil_layer s
SET ground_points = ( SELECT c.ground_points
FROM fields f
JOIN invekos i ON (f.f_id = i.field_id)
JOIN cultivation c ON (i.i_id = c.i_id)
WHERE i.request_year = r AND s.f_id = f.f_id)
WHERE s.ground_points IS NULL OR s.ground_points = 0;
END LOOP;
END
$BODY$
LANGUAGE plpgsql;
.
SELECT move_ground_points();