ORA-01804 error while trying to load "Oracle" dbDriver

Anthony O. picture Anthony O. · Jan 20, 2017 · Viewed 9.4k times · Source

I'm using ROracle and do the following commands in R:

Sys.getenv()
drv <- dbDriver("Oracle")

And here is the error I obtain after this last line:

Error in .oci.Driver(.oci.drv(), interruptible = interruptible, unicode_as_utf8 = unicode_as_utf8,  :
  Error while trying to retrieve text for error ORA-01804

I'm on RStudio Server working on a RHEL 5 server.

How could I avoid this error?

Answer

Anthony O. picture Anthony O. · Jan 20, 2017

You have to check those 2 points:

  • ORACLE_HOME environment variable must be defined
  • $ORACLE_HOME/lib path must be in LD_LIBRARY_PATH environment variable value

For example, if your ORACLE_HOME is /usr/lib/oracle/12.1/client64 (which is the default in Oracle Instant Client installation with the official .rpm), execute the following R commands:

Sys.setenv("ORACLE_HOME" = "/usr/lib/oracle/12.1/client64")
Sys.getenv("LD_LIBRARY_PATH")
# Here check if /usr/lib/oracle/12.1/client64/lib is a part (separated by ":" of the result)
# else, append ":/usr/lib/oracle/12.1/client64/lib" to the result and set the environment variable using:
# Sys.setenv("LD_LIBRARY_PATH" = "/all/the/result:/of/getenv/command:/usr/lib/oracle/12.1/client64/lib")