On 9/14/2011 8:04 AM, Jody Garnett wrote:
Hello!
Happened when i tried to add some points to a layer (containing
POIs) loaded from a postgis database. I fired up eclipse enabled
trancing and this is what i got :
*Caused by: org.postgresql.util.PSQLException: ERROR: insert or
update on table "poi" violates foreign key constraint "poi_id_cat_fkey"*
Detail: Key (id_cat)=(0) is not present in table "poi_categ".
at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062)
Now programatically this could be settled with an input box asking
for an FK value that respects the constraints on that att, but i'm
curious why this hasn't been implemented in udig(is there maybe an
even easier solution which i'm missing? maybe an option which i did
not activate?)
I am not sure what to make of this error?it sounds like a problem
coming out of your database?
Yes it's because my POI table is normalized ( i created another
table with POI categories which is refernced by a FK in the POI table).
The id of the categories starts from 1 and udig tries by default to
insert a value of 0 for the FK (which obvioously isn't valid). Solutions
to this issue would be i think :
1)an input box asking for an FK value that respects the constraints on
that attribute (with a button to cancel in which case the point is not
added to the layer)
2)create a temporary ( shadow/invisible to the user) layer . This layer
will be associated with another "real" layer like the one containing my
DB data, so any change in style or whatever done to the
master/"real"/visible layer propagates to the invisible layer(s) .
Once the user clicks insert/commit, it tries to add the new data to the
DB table.
* Suggestion:It would be helpful for a user if Udig could
somehow detect ,in case a PSQL exception is thrown, what
attributes are involved in the error or at the very least show
the error message
Did you create the table with the datastore createSchema?
I did not create any table using geotools/udig api ; the tables were
already created in Postgresql. I just wanted to add some data from
within udig 1.2.2
Usually we do not run the tables with much by way of constraints
(beyond what postgis applies).
Please rephrase this. I'm not sure i understood this correctly but
you're saying udig was not tested in a case were the table whose geom
data is to be rendered has a NOT NULL FK?
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel