I have installed the oracle_fdw plugin for postgreSql and have reached a point where I could create a foreign table. But when I try to query this table, I get the following error:
ERROR: error connecting to Oracle: OCIEnvCreate failed to create environment handle
I went through the following thread where this exact issue is discussed:
OCIEnvCreate failed to create environment handle. #133
The thing is that I am not able to set the env variable for ORACLE_HOME. Below is the command to check the env and the corresponding output of the running postgres process:
:$ sudo cat /proc/4885/environ | xargs -0 -n 1 echo | sort
LANG=en_IN
PGDATA=/var/lib/postgresql/9.6/main
PG_GRANDPARENT_PID=4880
PGLOCALEDIR=/usr/share/locale
PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
PGSYSCONFDIR=/etc/postgresql-common
PWD=/
I have tried to export this variable in all possible places but to no avail. I referred the following threads:
Thus I have added env variables in the following files: (after loging in as postgres using sudo su postgres)
~/.bashrc
~/.bash_profile
~/.bash_login
~/.login
~/.profile
/etc/profile
In all of these files I have the following line:
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe/
Am I missing something here?
PS: I am on Ubuntu 17.10 using Postgres 9.6
sudo su - postgres? (the extra hyphen is important)postgresuser in Linux, then try to runsqlplusor any other Oracle client tool from there. Once you get that working, chances are the Postgres process can successfully create an OCI connection.