I'm using pgsql2shp.exe from a Windows batch file and I get an error when using a WITH clause:

    "C:\Program Files\PostgreSQL\9.4\bin\pgsql2shp.exe" [ ... ] "WITH test AS (SELECT gid, the_geom FROM siveer_aep.geo_c_3_0_3) SELECT * FROM test"

The [ ... ] stands for options I consider pointless here.

I have tried a simple query that runs fine. The error output is:

Table geo_c_3_0_3) SELECT * FROM test does not exist

It looks like WITH clause syntax is misinterpreted by the exec...

I have not found anything on the Internet about this issue. Any idea?

  • sql looks fine. Have you tried double quotes around the schema and/or table name e.g."siveer_aep"."geo_c_3_0_3"? You will probably need to escape these quotes as they're already inside double quotes. Not sure how you do that on windows but I'd try \" first. – Steven Kay Jun 26 '18 at 15:04
  • I get the following error: Table "geo_c_3_0_3") SELECT * FROM aep does not exist... – wiltomap Jun 27 '18 at 12:52
  • I see the same thing. You might want to try ogr2ogr instead, although I can't seem to get it to work at the moment. It might also be a problem with 'laundering' field names (keeping them 10 characters or less), I think ogr2ogr does this but i'm not sure about pgsql2shp – Steven Kay Jun 27 '18 at 16:49

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.