From: Peevee <peevee12@yahoo.com>
To: pgsql-bugs@postgresql.org
Subject: BUG #5813: Cross Database Access in the same server using DBlink
Date: Wed, 5 Jan 2011 11:20:46 GMT
Message-ID: <201101051120.p05BKkgQ046232@wwwmaster.postgresql.org> (raw)
The following bug has been logged online:
Bug reference: 5813
Logged by: Peevee
Email address: peevee12@yahoo.com
PostgreSQL version: 9.0.2
Operating system: Windows 7
Description: Cross Database Access in the same server using DBlink
Details:
I have created a table named "TestTableA" in a Database named "DatabaseA"
and created again another table named "TestTableB" in "DatabaseB".
CREATE TABLE "TestTableA"
(
"Name" character varying(50)[],
"TableId" serial NOT NULL,
CONSTRAINT "pk_tableID" PRIMARY KEY ("TableId")
)
WITH (
OIDS=FALSE
);
ALTER TABLE "TestTableA" OWNER TO postgres;
CREATE TABLE "TestTableB"
(
"TableId" serial NOT NULL,
"Name" character varying(50)[],
CONSTRAINT "pk_tableID" PRIMARY KEY ("TableId")
)
WITH (
OIDS=FALSE
);
ALTER TABLE "TestTableB" OWNER TO postgres;
Now I'm trying to access "TableB" which is located in "DatabaseB" from my
function located in "DatabaseA".
create or replace function TestFunction(pInput character varying) RETURNS
VOID as
$$
DECLARE
rec record;
BEGIN
SELECT * from dblink('dbname=DMATempLog port=5432 user=postgres
password=somepassword','Select TableName from TestTableB LIMIT 1' )as
rec(tablename character varying(50));
END;
$$ language plpgsql;
and this generates an error:
ERROR: relation "testtableb" does not exist
CONTEXT: Error occurred on dblink connection named "unnamed": could not
execute query.
SQL statement "SELECT * from dblink('dbname=DMATempLog port=5433
user=postgres password=Pv12062010igen','Select TableName from testtableb
LIMIT 1' )as rec(tablename character varying(50))"
PL/pgSQL function "testfunction" line 12 at SQL statement
********** Error **********
ERROR: relation "testtableb" does not exist
SQL state: 42P01
Context: Error occurred on dblink connection named "unnamed": could not
execute query.
SQL statement "SELECT * from dblink('dbname=DMATempLog port=5433
user=postgres password=Pv12062010igen','Select TableName from testtableb
LIMIT 1' )as rec(tablename character varying(50))"
PL/pgSQL function "testfunction" line 12 at SQL statement
I'm solving this problem for almost 1 week..could you please help me..i read
a lot about dblink and try all their suggestions but none of them works.Am i
missing something here?
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: peevee12@yahoo.com
Subject: Re: BUG #5813: Cross Database Access in the same server using DBlink
In-Reply-To: <201101051120.p05BKkgQ046232@wwwmaster.postgresql.org>
References: <201101051120.p05BKkgQ046232@wwwmaster.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox