[Qgis-user] Re: Can't load PostGIS views

Mathieu Ouellette ouellette.mathieu at gmail.com
Mon Nov 21 09:51:39 PST 2011


Thank you Noli and Regis! Those are great ways to solve this problem.

Well I finally manage to load the views by doing the folowing steps:

1 - In the base table, I defined the unique constraint directly on the
column (ex: my_column_id serail UNIQUE NOT NULL)  instead of a table
constraint (ex: UNIQUE (my_column_id)).

2 - In the views, I had to remove the alias for the id column.

Mathieu

2011/11/18 Mathieu Ouellette <ouellette.mathieu at gmail.com>

> Hi,
>
> I have a PostGIS database and I'm trying to load some views in QGIS 1.7
> but it doesn't work. The error message title is in French but basically it
> says that QGIS can't find an appropriate primary key. The message regarding
> the column which would normally acts as a primary key is in French again
> but it says that is not suitable because its type is int4 and it doesn't
> have constraints.
>
> However, this column has a primary key constraint in the base table, has a
> unique constraint and is set to NOT NULL... I also created a test view in
> which the select query is identical to the base table (no joins, no alias,
> ...) and the same error happens (while the base table is loading
> perfectly). In order to push further, I made a SELECT DISTINCT query on my
> id column and a SELECT COUNT(DISTINCT my_id_column) on both the base table
> and the test view and I got the same numbers so the values of this column
> are really unique. I also loaded my views in uDig and I got no problem.
>
> Does anybody have any idea on what could be causing this problem?
>
> Thanks a lot,
>
> Mathieu
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20111121/5b3b730b/attachment.html>


More information about the Qgis-user mailing list