5

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

2 Answers 2

6

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

3
  • @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, 2013 at 22:23
  • @PeterIvan thank you, but I do not really know how stackexchange works. I just accecpted this answer.
    – aborruso
    Feb 2, 2013 at 9:33
  • @aborruso: OK, be welcome. Reading FAQ might help: gis.stackexchange.com/faq#howtoask
    – Peter Ivan
    Feb 2, 2013 at 9:53
2

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"
2
  • 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, 2012 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, 2012 at 11:31

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.