<div dir="ltr">Hi Mateusz,<br><br>thanks for the help and the sample! I will try to implement it. I have also received a sample from an Oracle DBA how to create a Batch file with a properly defined command line while executing an SQL script with some PL/SQL procedures.<br>
<br>If interested, I will send it to you, when completed developing and testing it.<br><br>Best regards,<br><br>Dejan<br><br><div class="gmail_quote">On Thu, Aug 7, 2008 at 5:42 PM, Mateusz Loskot <span dir="ltr">&lt;<a href="mailto:mateusz@loskot.net">mateusz@loskot.net</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">D wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
I have a question about the usage of OGR2OGR in defining an ESRI Shapefile<br>
output name. I am exporting Spatial data from Oracle Spatial (11g) from a<br>
single table to an ESRI Shapefile and would like to get the following naming<br>
syntax for my Shapefile:<br>
<br>
<br>
[select distinct FIELD1 from SHEMA.TABLE][select distinct FIELD2 from<br>
SHEMA.TABLE][fixed value -&gt; 01]<br>
<br>
.. the output would look like<br>
<br>
50000002806200701.shp<br>
50000002806200701.shx<br>
50000002806200701.dbf<br>
<br>
The naming parts/chunks that are concatenated here are actually queries in<br>
the source database (Oracle).<br>
</blockquote>
<br></div>
D,<br>
<br>
It&#39;s not possible to get it done with ogr2ogr only. You need to write a script.<div class="Ih2E3d"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Any examples (sample scripts, procedures) or hints on how to implement this,<br>
would be very helpful.<br>
</blockquote>
<br>
<br></div>
Here you have a prototype of how it can be solve with Python:<br>
<br>
#################################<br>
import os<br>
import cx_Oracle<br>
<br>
connstr = &#39;system/pantera@localhost&#39;<br>
conn = cx_Oracle.connect(connstr)<br>
cur = conn.cursor()<br>
<br>
# build your SQL queries<br>
cur.execute(&#39;SELECT DISTINCT NAME FROM TEST_POINTS&#39;)<br>
row = cur.fetchone()<br>
i = 0<br>
while row is not None:<br>
 &nbsp; &nbsp;# generate filename<br>
 &nbsp; &nbsp;prefix = row[0]<br>
 &nbsp; &nbsp;name = prefix + &#39;_%02d&#39; % i<br>
<br>
 &nbsp; &nbsp;# call ogr2ogr and pass the generate name as output file name<br>
 &nbsp; &nbsp;os.system(&#39;ogr2ogr -f &quot;ESRI Shapefile&quot; %s.shp ....&#39; % name)<br>
 &nbsp; &nbsp;...<br>
<br>
 &nbsp; &nbsp;# read next record<br>
 &nbsp; &nbsp;row = cur.fetchone()<br>
 &nbsp; &nbsp;i = i + 1<br>
<br>
if cur is not None:<br>
 &nbsp; &nbsp;cur.close()<br>
if conn is not None:<br>
 &nbsp; &nbsp;conn.close()<br>
#################################<br>
<br>
Best regards,<br><font color="#888888">
-- <br>
Mateusz Loskot, <a href="http://mateusz.loskot.net" target="_blank">http://mateusz.loskot.net</a><br>
Charter Member of OSGeo, <a href="http://osgeo.org" target="_blank">http://osgeo.org</a><br>
</font></blockquote></div><br></div>