title: PostgreSql: Set environment variables
body: <p>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: </p>
  
  <p><code>ERROR:  error connecting to Oracle: OCIEnvCreate failed to create environment handle</code></p>
  
  <p>I went through the following thread where this exact issue is discussed:</p>
  
  <p><a href="https://github.com/laurenz/oracle_fdw/issues/133" rel="nofollow noreferrer"><strong>OCIEnvCreate failed to create environment handle. #133</strong></a></p>
  
  <p>The thing is that I am not able to set the env variable for <strong>ORACLE_HOME</strong>. Below is the command to check the env and the corresponding output of the running postgres process:</p>
  
  <pre><code>:$ 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=/
  </code></pre>
  
  <p>I have tried to export this variable in all possible places but to no avail. I referred the following threads:</p>
  
  <p><a href="https://unix.stackexchange.com/questions/117467/how-to-permanently-set-environmental-variables/117470">https://unix.stackexchange.com/questions/117467/how-to-permanently-set-environmental-variables/117470</a></p>
  
  <p><a href="http://www.linuxtopia.org/online_books/database_guides/Practical_PostgreSQL_database/PostgreSQL_x486_007.htm" rel="nofollow noreferrer">http://www.linuxtopia.org/online_books/database_guides/Practical_PostgreSQL_database/PostgreSQL_x486_007.htm</a></p>
  
  <p>Thus I have added env variables in the following files:
  (after loging in as postgres using <strong>sudo su postgres</strong>)</p>
  
  <pre><code>~/.bashrc
  ~/.bash_profile
  ~/.bash_login
  ~/.login
  ~/.profile
  /etc/profile
  </code></pre>
  
  <p>In all of these files I have the following line:</p>
  
  <p><code>export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe/
  </code></p>
  
  <p>Am I missing something here?</p>
  
  <p>PS: I am on Ubuntu 17.10 using Postgres 9.6</p>