Hi,<div><br></div><div>If data contain both LINESTRING and MULTILINESTRING, then you should use the MULTILINESTRING constraint. (this is the default shp2pgsql behavior, as you noted).</div><div><br></div><div>Concerning the trigger, this is a 2 step operation:</div>
<div>First you create the function the trigger will call</div><div>Then you create a trigger on a table using this function:</div><div><br></div><div><div><font face="courier new, monospace">-- function definition</font></div>
<div><font face="courier new, monospace">create or replace function forceMulti() returns trigger as $$</font></div><div><font face="courier new, monospace">    DECLARE</font></div><div><font face="courier new, monospace">    </font></div>
<div><font face="courier new, monospace">    BEGIN</font></div><div><font face="courier new, monospace">        NEW.geom := st_multi(NEW.geom);</font></div><div><font face="courier new, monospace">        RETURN NEW;</font></div>
<div><font face="courier new, monospace">    END;</font></div><div><font face="courier new, monospace">$$ LANGUAGE PLPGSQL;</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">-- then trigger creation</font></div>
<div><span style="font-family:'courier new',monospace">create trigger forceMulti_trigger </span><br></div><div><font face="courier new, monospace">    BEFORE UPDATE OR INSERT</font></div><div><font face="courier new, monospace">    ON profiles_line_wgs84 </font></div>
<div><font face="courier new, monospace">    FOR EACH ROW</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>EXECUTE PROCEDURE forceMulti();</font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace">insert into profiles_line_wgs84 (geom)</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>values ('srid=4326;LINESTRING(0 0, 1 1)'::geometry);</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">select st_astext(geom) from profiles_line_wgs84;</font></div></div><div><br></div><div>Nicolas</div>