HuFlungPu
HuFlungPu

Reputation: 561

ERROR: function dblink(unknown, unknown) does not exist

I have defined a foreign server pointing to another database. I then want to execute a function in that database and get back the results.

When I try this:

SELECT * FROM  dblink('mylink','select someschema.somefunction(''test'', ''ABC'')')

or this:

SELECT t.n FROM  dblink('mylink', 'select * from someschema.mytable') as t(n text)

I get the error:

ERROR: function dblink(unknown, unknown) does not exist

Running as superuser.

Upvotes: 36

Views: 44613

Answers (4)

Naveen Immadi
Naveen Immadi

Reputation: 1

I was also facing the same issue

  1. check dblink(text,text) function it is empty or not and check the function if its created propperly.
  2. use this command DROP EXTENSION IF EXISTS dblink CASCADE and re install i;

Upvotes: 0

Duilio
Duilio

Reputation: 1036

In my case the problem was that I was using a different user than the one I used to create the extension.

I solved it using the same user that ran the create extension dblink; command

Upvotes: 6

Vzzarr
Vzzarr

Reputation: 5680

In my case (as reported also in @HuFlungPu comments) the problem was that I initially created the dblink in public schema. I executed a SET search_path TO my_schema because I was working on my_schema; so when querying the dblink I was receiving

ERROR: function dblink(unknown, unknown) does not exist
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

After executing a SET search_path TO public (where 'public' is the schema in which the dblink was created) I was able to query again successfully through the dblink

Upvotes: 8

Roman Marusyk
Roman Marusyk

Reputation: 24589

You need to install an extension dblink

create extension dblink;

Upvotes: 57

Related Questions