Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I need to read an Oracle (not spatial) table with OGR.

I have no problem with ogrinfo. I use this command:

ogrinfo -ro OCI:user/password -sql "select * from HR.EMPLOYEES"

I have this kind of output:

OGRFeature(select * from HR.EMPLOYEES):106
  EMPLOYEE_ID (Integer) = 206
  FIRST_NAME (String) = William
  LAST_NAME (String) = Gietz
  EMAIL (String) = WGIETZ
  PHONE_NUMBER (String) = 515.123.8181
  JOB_ID (String) = AC_ACCOUNT
  SALARY (Real) =  8300.00
  COMMISSION_PCT (Real) = (null)
  MANAGER_ID (Integer) = 205
  DEPARTMENT_ID (Integer) = 110

Now I would like to export (in example) in CSV format, using OGR. This is the command:

ogr2ogr -f "CSV" test.csv OCI:"user/password" -sql "select * from HR.EMPLOYEES"

I have this errors:

ERROR 4: Failed to create test.csv\select * from HR.EMPLOYEES.csv:
Invalid argument
ERROR 1: Terminating translation prematurely after failed
translation from sql statement.

I'm not able to find the syntax error. What's wrong?

I'm using gdal/ogr 1.9 and Oracle 11g for windows.

Thank you,

Andrea

share|improve this question

2 Answers 2

up vote 5 down vote accepted

try adding -nlt NONE, in case it's a table without geometries

share|improve this answer
    
It works bro. Thank you very much! –  aborruso Nov 8 '12 at 12:11
    
@aborruso: Shall you accept this answer? Your question seems as unanswered and attracts work effort which is not needed. A collaboration site means ask, get answers and accept the best one. –  Peter Ivan Jan 31 '13 at 22:23
    
@PeterIvan thank you, but I do not really know how stackexchange works. I just accecpted this answer. –  aborruso Feb 2 '13 at 9:33
    
@aborruso: OK, be welcome. Reading FAQ might help: gis.stackexchange.com/faq#howtoask –  Peter Ivan Feb 2 '13 at 9:53

I suppose the -sql parameter should be positioned before the destination file:

ogr2ogr -f "CSV" -sql "select * from HR.EMPLOYEES" test.csv OCI:"user/password"
share|improve this answer
    
I have the same error: ERROR 4: Failed to create test.csv\select * from HR.EMPLOYEES.csv: Invalid argument ERROR 1: Terminating translation prematurely after failed translation from sql statement. –  aborruso Nov 8 '12 at 11:21
    
I have built my expression starting from this example - bquot.com/f6o - where it seems I can insert -sql paramater after destination file. –  aborruso Nov 8 '12 at 11:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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