Tag Archives: lightdb oracle_fdw Error

[Solved] lightdb oracle_fdw Error: ERROR: error connecting to Oracle: OCIEnvCreate failed to create environment handle

Error Messages:

create server oradb foreign data wrapper oracle_fdw options (dbserver '//10.20.30.199:1521/test');
create user mapping for USER server oradb options (user 'scott', password 'scott');
GRANT USAGE ON FOREIGN DATA WRAPPER oracle_fdw TO CURRENT_USER;
GRANT USAGE ON FOREIGN SERVER oradb TO CURRENT_USER;

create foreign table haha
( id int)
SERVER oradb OPTIONS (schema 'scott', table 'haha


[lightdb@hs-10-20-30-199 ~]$ ltsql -p 5435 -U scott -d scott
ltsql (13.3-22.2)
Type "help" for help.

scott@scott=# select * from haha;
ERROR: error connecting to Oracle: OCIEnvCreate failed to create environment handle
DETAIL:
scott@scott=#
scott@scott=#
scott@scott=#
scott@scott=#
scott@scott=#
scott@scott=#
scott@scott=# select * from haha;
ERROR: error connecting to Oracle: OCIEnvCreate failed to create environment handle
DETAIL:

 

Solution:
Install the oracle light client. The oracle client can be downloaded from https://www.oracle.com/database/technologies/instant-client/downloads.html .
export ORACLE_HOME=/home/lightdb/instantclient_21_6
export LD_LIBRARY_PATH=$ORACLE_HOME:$LD_LIBRARY_PATH
export TNS_ADMIN=$ORACLE_HOME/network/admin
Restart lightdb, the problem is solved.