Re: [postgis-users] check constraints violated - ¿how to fix this?

Guido Lemoine guido.lemoine at jrc.it
Tue Oct 25 06:44:00 PDT 2005


Your problem is that you define your geometry column with SRID = -1.
This becomes the enforce_srid_spos constraint on your table. Then, you
try to insert with SRID=4326, which fails the constaint check.

So, simple make it

SELECT AddGeometryColumn(
            'gs_inf', 'spos', 4326, 'POINT',
            2);

and your prob should be solved.

GL


ricardd at mathstat.dal.ca wrote:

>Hello postgis-users,
>Just a clarification about check constraints.
>
>I'm running postgis 1.0.3 with postgreSQL 8.0.3 on Linux. The
>spatial_ref_sys table was populated at installation with ESPG data using
>spatial_ref_sys.sql
>
>My data is from fisheries surveys and some records only have a starting
>position and no ending position. The spatial objects are defined as
>follows:
>
>SELECT AddGeometryColumn(
>            'gs_inf', 'spos', -1, 'POINT',
>            2);
>SELECT AddGeometryColumn(
>            'gs_inf', 'epos', -1, 'POINT',
>            2);
>
>
>I thought that I could use something like this to input data with missing
>end position:
>
>INSERT INTO gs_inf VALUES (GeomFromText('POINT(-66.7 44.8)',4326), NULL );
>
>However, I get the following error message:
>
>psql:gs_inf.sql.in:2: ERROR:  new row for relation "gs_inf" violates check
>constraint "enforce_srid_spos"
>
>Any suggestions how I can solve this? Setting the srid to -1 solves the
>problem but I'm curious if there is another way.
>Cheers,
>
>Dan
>
>
>_______________________________________________
>postgis-users mailing list
>postgis-users at postgis.refractions.net
>http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>  
>



More information about the postgis-users mailing list