Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
334 views
in Technique[技术] by (71.8m points)

postgresql - ERROR: connection for foreign table "test_enames" cannot be established

I am getting below error while selecting the foreign table from Postgres & please help me on fixing the issue.

ERROR: connection for foreign table "test_enames" cannot be established

DETAIL: ORA-12154: TNS:could not resolve the connect identifier specified

SQL state: HV00N

Details

1.I am using Postgres 13 version on Windows 10 64 Bit machine.

2.I installed oracle_fdw-2.3.0-pg13-win64 successfully in my Windows 10 6bit machine.

3.Created system variable for TNS_ADMIN=C:Oracleproduct12.2.0x64client_1 etworkadmin

4.Created below steps successfully.

CREATE FOREIGN DATA WRAPPER oracle_fdw

CREATE SERVER foreign_oracle
TYPE 'Oracle12'
VERSION '12'
FOREIGN DATA WRAPPER oracle_fdw
OPTIONS (dbserver '//vms1.abc.com:1524/ABC00D70');

CREATE USER MAPPING FOR postgres SERVER foreign_oracle
OPTIONS ("user" 'Test', password 'Test1');

CREATE FOREIGN TABLE test_enames(
eno numeric NULL,
ename character varying(100),
eloc character varying(100)
) SERVER foreign_oracle
OPTIONS (table 'TEST_ENAMES');

But still getting error while selecting table , let me know incase if i missed any steps.

Thanks


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

That seems like an Oracle configuration problem. To debug this, try running the following as the operating system user that runs the PostgreSQL service:

sqlplus Test/Test1@//vms150.abc.com:1524/ABC00D70

If that doesn't work, start debugging that. That should be easier, since oracle_fdw is not part of the equation then.

If the sqlplus call above works as you intend it to, make sure that the PostgreSQL service has the TNS_ADMIN environment variable set (did you restart the service after setting it?). I am not sure how to check the environment for a running process on Windows, but "Process Explorer" might do the trick.

Besides, you shouldn't use CREATE FOREIGN DATA WRAPPER to create the FDW, but create the extension as specified in the documentation:

CREATE EXTENSION oracle_fdw;

That will create the foreign data wrapper for you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...