Hi,

If data contain both LINESTRING and MULTILINESTRING, then you should use
the MULTILINESTRING constraint. (this is the default shp2pgsql behavior, as
you noted).

Concerning the trigger, this is a 2 step operation:
First you create the function the trigger will call
Then you create a trigger on a table using this function:

-- function definition
create or replace function forceMulti() returns trigger as $$
    DECLARE

    BEGIN
        NEW.geom := st_multi(NEW.geom);
        RETURN NEW;
    END;
$$ LANGUAGE PLPGSQL;

-- then trigger creation
create trigger forceMulti_trigger
    BEFORE UPDATE OR INSERT
    ON profiles_line_wgs84
    FOR EACH ROW
EXECUTE PROCEDURE forceMulti();

insert into profiles_line_wgs84 (geom)
values ('srid=4326;LINESTRING(0 0, 1 1)'::geometry);

select st_astext(geom) from profiles_line_wgs84;

Nicolas
_______________________________________________
postgis-users mailing list
[email protected]
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users

Reply via email to