[Qgis-user] Help to load a postgis view on QGIS : primary key required

Bernhard Ströbl Bernhard.Stroebl at jena.de
Fri Sep 25 02:40:24 PDT 2009


Hi Lore,

AFAIK you _must_ define the gid field as a primary key in your base 
table, it does not matter if it can be considered to be one.

ALTER TABLE calendrier_activite ADD PRIMARY KEY (gid);

Bernhard

Lore M schrieb:
> Hi 
> 
> I have kind of an ordinary (but still thorny) problem with Qgis (version 1.0.2kore) when I try to load a postgis layer. I'm sorry because there is several posts about this problem but neither of the solutions proposed solve my own problem...
> 
> So, I've got two tables in my postgreSQL database and I create a view from them.
> 
> -- View: calendrier_area
> CREATE OR REPLACE VIEW calendrier_area AS 
>  SELECT calendrier_activite.gid, calendrier_activite.annee, calendrier_activite.mois, calendrier_activite.navire_code, calendrier_activite.zone, ciem_areas.ices_area, ciem_areas.the_geom
>    FROM calendrier_activite, ciem_areas
>   WHERE "substring"(calendrier_activite.zone::text, 1, 4) = "substring"(ciem_areas.ices_area::text, 1, 4);
> ALTER TABLE calendrier_area OWNER TO postgres;
> 
> The attribute "gid" from the table "calendrier_activite" is UNIQUE (I check this with "SELECT DISTINCT * FROM calendrier_area;" and there is as many lines as in table "SELECT * FROM calendrier_area"). Moreover, "gid" type is "serial" so "int4". Therefore, calendrier_area.gid can be considered as a PRIMARY KEY in the view.
> 
> For all that, I can't load this view in Qgis : it still ask me for PRIMARY KEY in the view calendrier_area.
> 
> Do you any idea please ??? Thanks everyone
> 
> Lore
>  
>  		 	   		  
> _________________________________________________________________
> Découvrez toutes les possibilités de communication avec vos proches
> http://www.microsoft.com/windows/windowslive/default.aspx
> 
> ________ Information from NOD32 ________
> This message was checked by NOD32 Antivirus System for Linux Mail Server.
> http://www.nod32.com
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
> 
> 
> ________ Information from NOD32 ________
> This message was checked by NOD32 Antivirus System for Linux Mail Server.
> http://www.nod32.com

-- 
Dipl.-Geogr. Bernhard Ströbl
Anwendungsbetreuer GIS
Kommunale Immobilien Jena
  - Datenverarbeitung -
mailto:Bernhard.Stroebl at jena.de
http://kij.jena.de/
----------------------------


________ Information from NOD32 ________
This message was checked by NOD32 Antivirus System for Linux Mail Server.
http://www.nod32.com



More information about the Qgis-user mailing list