[postgis-users] Fwd: constraint violation : enforce_geotype_the_geom
nicolas.ribot at gmail.com
Tue Jul 27 05:37:55 PDT 2010
> Hello, there
> I'm quite new to postgis requests and I've got a constraint violation
> problem with one of my requests:
> create table bati_buff (id serial primary key);
> select addgeometrycolumn ('bati_buff', 'the_geom', 27572, 'POLYGON', 2 ) ;
> insert into bati_buff (the_geom)
> (select bati.the_geom from bati, buffer where intersects (bati.the_geom,
> buffer.the_geom) =true ) ;
> I have a constraint violation with the relation enforce_geotype_the_geom.
> How can I solve it ?
> Guillaume Longuetaud
This indicates the return of the subselect is not a POLYGON.
What is the geometric type of the bati.the_geom table ? (could it be
MULTIPOLYGON, maybe coming from a shp2pgsql command ?)
Having constraints is good in the sense it guarantees a unique
geometric type to be stored in the table, thus avoiding later errors
when calling functions that support only one type.
If the subselect geometry type is a multipolygon with one object, you
can extract the polygon from the collection with st_geometryN(geom,
If you want to store multiple types into the column, you can also drop
the constraint on the table.
More information about the postgis-users