1

I'm trying to visualize some of my database queries on qGIS. I run a valid SQL query which returns a subset of my table that should be easily loaded as a layer. I then check "Load as new layer," selected the right id and geom columns and typed in a new layer name. Then, I clicked "Load Now!." qGIS does some thinking and things pause for a second, but no new layer is created. No error messages are thrown. Thanks in advance.

EDIT: It turns out that add a new layer is throwing an error :$. Let me provide some more detail. I'm trying to do a pgrouting query and display the results. My database table is qc28l. When I run this query:

      SELECT * FROM qc28l
   JOIN (SELECT seq, id1 AS node, id2 AS edge_id, cost FROM pgr_dijkstra('
        SELECT gid AS id, source::integer, target::integer, miles::double precision AS cost FROM qc28l',
                747, 311, false, false)
   ) 
AS route ON qc28l.gid = route.edge_id;

I get a valid-looking table and there are no errors. When I click the Add layer option, this query is embedded in more SQL syntax (and, you'll have to forgive me, I'm a bit of an SQL newb though I do know more traditional programming languages). The error that trying to add a new layer gives is:

Unable to execute the query.
The error message from the database was:
ERROR:  syntax error at or near ";"
LINE 6: AS route ON qc28l.gid = route.edge_id;
                                             ^
.
SQL: SELECT * FROM (SELECT * FROM qc28l
   JOIN (SELECT seq, id1 AS node, id2 AS edge_id, cost FROM pgr_dijkstra('
        SELECT gid AS id, source::integer, target::integer, miles::double precision AS cost FROM qc28l',
                747, 311, false, false)
   ) 
AS route ON qc28l.gid = route.edge_id;
) AS "subQuery_0" LIMIT 1

Thanks in advance.

  • Could you please provide the the query you are using? – Alexandre Neto Apr 11 '14 at 14:21
  • Sure, just added a bunch more detail. Above. Thanks for your help. – user2938099 Apr 11 '14 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.