Tuesday, 6 December 2016

QGIS returns "Invalid Layer" message when trying to add PostGIS view?



I'm new to Postgis and QGIS. I created a view defined as


CREATE OR REPLACE VIEW pupr.vstudentmuni AS 
SELECT m.id AS munid, m.name AS muname, m.geom, s.code,
(s.name::text || ' '::text) || s.lastname::text AS fullname
FROM pupr.municipio m, pupr.student_location l, pupr.student s
WHERE st_within(l.geom, m.geom) AND s.code = l.code;

in PostgreSQL. Trying to add this view to QGIS returns the following error...


"Invalid layer"..."sql= is an invalid layer and cannot be loaded."


Not sure what the problem is. The table is mentioned in the geommetry_columns table in PostGIS, but I can see a message entry in QGIS that says "No key field for given view". I'm using PostgreSQL 9.2 and QGIS 1.8.0.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...