[gdal-dev] Retreivinng a table with a condition using ogr2ogr OCI

Ammar ammar83_h at yahoo.com
Tue Apr 21 02:08:53 PDT 2015


Hello all,
I am using ogr2ogr OCI driver to convert an Oracle table to a shape file. The command I am using is (it works perfectly):

ogr2ogr 3011 -f "ESRI Shapefile" OCI:"user/password@(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)))(CONNECT_DATA = (SID =MY_SID))):TABLE" 

Now, I am trying to use the -sql option so that to retrieve a table only if the condition is true but I am having trouble getting the command to work. The command I'm using is:
ogr2ogr 3011 -f "ESRI Shapefile" OCI:"user/password@(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)))(CONNECT_DATA = (SID =MY_SID))):TABLE"  -sql "SELECT * FROM TABLE WHERE DETAILTYPE = 'Something'"
and I am getting the following error message:
layer names ignored in combination with -sql.
ERROR 1: Failed to create file .shp file.
ERROR 4: Failed to open Shapefile `3011\SELECT * FROM TABLE WHERE DETAILTYPE = 'Something'.shp'.

ERROR 1: Terminating translation prematurely after failed
translation from sql statement.
How can I get ogr2ogr to work with -sql?

I am using GDAL 1.11.1, released 2014/09/24 on Windows 64-bits.
Thanks in advanceAmmar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20150421/e8db14c6/attachment.html>


More information about the gdal-dev mailing list