5

I have a view, named PointsForGpxExport, that contains points I want to export to a GPX file. The ogr2ogr command I'm trying to use for the export is included below. When I run the command, a GPX file is created. The file is a shell of a GPX file - headers and root element but none of the data from the view. An error is reported.

The error reported is

ERROR 1: ERROR: relation "pointsforgpxexport" does not exist
LINE 1: DECLARE executeSQLCursor CURSOR for SELECT * FROM PointsForG... 

The command:

ogr2ogr-f GPX c:\temp\points.gpx PG:"host=localhost port=5432
dbname=SpatialPlayground schemas=public user=postgres password=password"
-sql "SELECT * FROM PointsForGpxExport"

When I run SELECT * FROM PointsForGpxExport inside the pgAdmin tool, an error occurs ERROR: relation "pointsforgpxexport" does not exist I resolved this error by including the schema name in the query as in SELECT * FROM "public"."PointsForGpxExport"; This error is identical to the error I'm getting when I run ogr2ogr and I thought it would be resolved by using schemas=public in the connection string.

What am I doing wrong and how do I fix this?

PostgreSQL 9.3, PostGIS 2.1.6, GDAL 1.11.2 released 2015/02/10

10

This is a case sensitivity/quoting issue.

"PointsForGpxExport" and PointsForGpxExport are not the same table name.

PostgreSQL, per the SQL standard, case-folds unquoted identifiers. (It case-folds to lowercase, where the standard says uppercase, though). So when you write PointsForGpxExport, PostgreSQL treats that as the same as pointsforgpxexport. Since table names are case sensitive, and you created your table as "PointsForGpxExport" (possibly via a GUI tool that always quotes table names), there's no such table as pointsforgpxexport. Hence the error.

When you quote table names, do so consistently - everywhere or nowhere. In this case you need to either:

ALTER TABLE "PointsForGpxExport" RENAME TO pointsforgpxexport;

or use "PointsForGpxExport" in your queries.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.