<div dir="ltr"><div>Good evening,</div><div><br></div><div>I have a postgis polygons table for my "cities".<br>I have a point table for my "boreholl".<br><br>I created a "mv" materialized view defined by a spatial join as follows:<br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">    SELECT boreholl.*,<br>    cities.gid,<br>    cities.insee_id,<br>    <a href="http://cities.name">cities.name</a><br>    FROM boreholl, cities<br>    WHERE st_intersects(boreholl.geom, cities.geom);<br></blockquote><br>Now I want as soon as an updating takes place for the "cities_name" column of my "cities" polygon table,<br>this change also occurs in the "name" column of my materialized view.<br><br>As far i understood,the trigger must be defined on the "cities" table as follows :<br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">    CREATE TRIGGER cities_trigger<br>    after  update<br>    on cities<br>    FOR EACH STATEMENT. <br>    execute procedure trigger_fonction<br></blockquote><br><br>Now I need to define the function. It is for this step that I need you.<br>Below, a proposed structure. But a lot is missing :<br><br><br><blockquote>    CREATE or replace FUNCTION  trigger_fonction<br>    returns trigger<br>    langage sql<br>    AS $$<br>    BEGIN<br>     if    then<br>    update<br>    end if ;<br>    return new<br>    refresh materialized view<br>    END;<br>    $$<br></blockquote><br>Thanks a lot. </div></div>