0

I have a table with two geometry types, one with WGS 87 (4326, polygon) and the other with 5347 (local proyection, planar). When the table with 5437 is created or updated in QGIS, the trigger should update this row on 4326.

My problem is, when I save the changes I get:

  Postigs error adding spatial object: ERROR:  the column «geom» does not exist.
LINE 1: SELECT (st_dump(st_transform(geom,4326))).geom
                                     ^
QUERY:  SELECT (st_dump(st_transform(geom,4326))).geom
CONTEXT:  function PL/pgSQL varios.simple() line 6

Trigger:

CREATE OR REPLACE FUNCTION varios.simple()
  RETURNS trigger AS
$BODY$
    BEGIN
        IF NEW.id IS NULL THEN
            RAISE EXCEPTION 'id no puede ser null';
        END IF;
        NEW.simple = (st_dump(st_transform(geom,4326))).geom;
        RETURN NEW;
    END;
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
ALTER FUNCTION varios.simple() OWNER TO postgres;
GRANT EXECUTE ON FUNCTION varios.simple() TO public;
GRANT EXECUTE ON FUNCTION varios.simple() TO postgres;

CREATE TRIGGER "simple" BEFORE INSERT OR UPDATE ON capas_gral.asentamientos
    FOR EACH ROW EXECUTE PROCEDURE varios.simple();

  • Don't you need to refer to new.geom? – John Powell Jul 2 '18 at 16:50
  • CREATE OR REPLACE FUNCTION varios.simple() RETURNS trigger AS $BODY$ BEGIN IF NEW.geom IS NULL THEN RAISE EXCEPTION 'id no puede ser null'; END IF; NEW.simple = (st_dump(st_transform(geom,4326))).geom; RETURN NEW; END; $BODY$ LANGUAGE plpgsql VOLATILE ALTER FUNCTION varios.simple() OWNER TO postgres; GRANT EXECUTE ON FUNCTION varios.simple() TO public; GRANT EXECUTE ON FUNCTION varios.simple() TO postgres; The same error. Errores del proveedor: Error de PostGIS to add spatial objet: don't exixts column <geom» – Nahuel Atienza Jul 3 '18 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.