Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL DBLink: No function matches the given name and argument types

Tags:

sql

postgresql

I was playing around with DBLINK and I wanted to try it. So I run this simple query

CREATE EXTENSION dblink;

SELECT *  
FROM dblink(('dbname=genesis_admin')::text,
      ('SELECT * FROM user_account')::text);

then to my surprise

[WARNING  ] CREATE EXTENSION dblink
            ERROR:  extension "dblink" already exists
[WARNING  ] SELECT *  FROM dblink(('dbname=genesis_admin')::text, ('SELECT * FROM user_account')::text)
            ERROR:  function dblink(text, text) does not exist
            LINE 1: SELECT *  FROM dblink(('dbname=genesis_admin')::text, ('SELE...
                                   ^
            HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

How can it not be existing if it already exists?

like image 288
user962206 Avatar asked Apr 08 '15 14:04

user962206


People also ask

Why does a function call return a different name for each argument?

This happens if the function call has just one argument and the function name is the same as the (internal) name of some data type.

Why can't I find dblink (text) in the database?

The Database although contains the function DBlink (text, text) is therefore unable to find that function. To get this to work, you need to add specific schema to the DBlink function call.

How are functions of different argument types considered when searching?

If a qualified function name was given, only functions in the specified schema are considered. If the search path finds multiple functions of identical argument types, only the one appearing earliest in the path is considered. Functions of different argument types are considered on an equal footing regardless of search path position.


1 Answers

I encountered the same error and the reason is that this is because DBLink gets installed (by default) in Public schema and you have probably modified the search_path to a list that doesn't include public). The Database although contains the function DBlink(text, text) is therefore unable to find that function.

To get this to work, you need to add specific schema to the DBlink function call.

SELECT public.dblink(xxx, yyy);
like image 65
Robins Tharakan Avatar answered Oct 20 '22 17:10

Robins Tharakan