Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7711705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:26:36+00:00 2026-06-01T01:26:36+00:00

dblink does not seem to work when I use a named connection to a

  • 0

dblink does not seem to work when I use a named connection to a remote server or an unnamed connection and disconnect. It works fine if I use an unnamed connection with a connection string in dblink(). It appears to connect fine, but my connection is not available when I try to use it. Any ideas on how to get this working with named connections?

Unnamed with connstr Works Fine:

SELECT testtable.*
FROM   dblink('dbname=testdb port=5432 host=192.168.1.1 user=usr password=pw'
             ,'SELECT * FROM testtable')
AS     testtable(testtable_id integer, testtable_name text);

Returns: Two columns as expected.

Named Does not Work:

Connect:

SELECT dblink_connect('myconn'
           ,'dbname=testdb port=5432 host=192.168.1.1 user=usr password=pw');

Returns: “OK”

Query:

SELECT testtable.* FROM dblink('myconn', 'SELECT * FROM testtable')
AS     testtable(testtable_id integer, testtable_name text);

Returns:

ERROR:  could not establish connection
DETAIL:  missing "=" after "myconn" in connection info string

********** Error **********

ERROR: could not establish connection
SQL state: 08001
Detail: missing "=" after "myconn" in connection info string

Disconnect:

SELECT dblink_disconnect('myconn');

Returns:

ERROR:  connection "myconn" not available

********** Error **********

ERROR: connection "myconn" not available
SQL state: 08003

Unnamed with _connect and _disconnect Does not Work:

Connect:

SELECT dblink_connect('dbname=testdb port=5432 host=192.168.1.1
                                               user=usr password=pw');

Returns: “OK”

Query:

SELECT testtable.* FROM dblink('SELECT * FROM testtable')
AS testtable(testtable_id integer, testtable_name text);

Returns:

ERROR:  connection not available

********** Error **********

ERROR: connection not available
SQL state: 08003

Disconnect:

SELECT dblink_disconnect();

Returns:

ERROR:  connection not available

********** Error **********

ERROR: connection not available
SQL state: 08003
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:26:38+00:00Added an answer on June 1, 2026 at 1:26 am

    I have a working setup with unnamed connections.

    What you call “Unnamed” in your question, actually has a name parameter in it. You are confusing the two variants there. Try that without 'myconn':

    SELECT *
    FROM   dblink('SELECT * FROM testtable'
            ) AS testtable (testtable_id integer, testtable_name text);
    

    And remember that establishing the connection and using it has to happen in the same session.


    But I honestly cannot find what’s wrong with your named connection. I have run a few tests and everything looks correct. I tested with PostgreSQL 9.1.

    The error message implies that dblink expects a connstr. That only happens if the first parameter does not match any connname in existence In short: the connection 'myconn' is not found – which makes me suspect that you are not calling dblink() in the same session as dblink_connect().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to programmatically create a DBLink in SQL server 2005 in C#?
From the answers to calling a stored proc over a dblink it seems that
I'm trying to use DbLinq with a SQLite database, but I'm running into a
I am trying to display some xml data from remote URL using jquery and
Please let me know how to create Oracle DBLink in the same SID for
Related Link: String literals and escape characters in postgresql Here is my error: ERROR:
The purpose of the code is to find a portion of a string (from
Can I use the Database Link tool in Apex to connect to MS SQL
im not sure if this is possible or not, but im trying to alter
i, I have one Materialized view on one server which is created by DB

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.