Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Novice > Dataim****t fro...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 3169 of 3323
Post > Topic >>

Dataim****t from remote db

by tobias.schoenit@[EMAIL PROTECTED] ("Schoenit, Tobias AT/BHL-ZTPS") Jul 11, 2008 at 01:28 PM

This is a multi-part message in MIME format.

------_=_NextPart_001_01C8E349.3BCEB1EB
Content-Type: text/plain;
	charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

Hello,

i have several machines having the same database layout. Now i want
im****t data from a remote machine.=20

I tried something like this:

CREATE OR REPLACE FUNCTION im****t_sc(text)
  RETURNS int4 AS $$
	DECLARE
		v_host		ALIAS FOR $1;
		v_return	int4;
		v_constr	text;
		v_config		record;
		temp		record;
	BEGIN
		v_constr :=3D 'hostaddr=3D' || v_host || ' dbname=3Dconfig
user=3Duser password=3Dpass';

		-- connect to remote database
		PERFORM 'SELECT dblink_connect(''con'', v_constr);';
		RAISE NOTICE 'connected';

		FOR v_config in (SELECT * from  dblink('''con''',
'SELECT * from config ') AS
		  hc(id character(36), name text))=20
		LOOP
			INSERT INTO config (id, name) values
(v_config.id, v_config.name);
		END LOOP;

		PERFORM 'SELECT dblink_disconnect (''con'');';
	=09
		v_return :=3D 4;
		RETURN v_return;

	END;
$$ LANGUAGE 'plpgsql';


But now I get:
NOTICE:  connected

ERROR:  could not establish connection
DETAIL:  missing "=3D" after "'con'" in connection info string

CONTEXT:  PL/pgSQL function "im****t_sc" line 13 at FOR over SELECT rows

********** Fehler **********

ERROR: could not establish connection
SQL Status:08001
Detail:missing "=3D" after "'con'" in connection info string
Kontext:PL/pgSQL function "im****t_sc" line 13 at FOR over SELECT rows


What does that mean?

Thank you very much.
Tobias

------_=_NextPart_001_01C8E349.3BCEB1EB
Content-Type: text/html;
	charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3DUS-ASCII">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
6.5.7652.24">
<TITLE>Dataim****t from remote db</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=3D2 FACE=3D"Arial">Hello,</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">i have several machines having the same =
database layout. Now i want im****t data from a remote machine. </FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">I tried something like this:</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">CREATE OR REPLACE FUNCTION =
im****t_sc(text)</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">&nbsp; RETURNS int4 AS $$</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">DECLARE</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">v_host&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
ALIAS FOR $1;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">v_return&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
int4;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">v_constr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
text;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">v_config&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; record;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">temp&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; record;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">BEGIN</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">v_constr :=3D 'hostaddr=3D' || v_host || ' =
dbname=3Dconfig user=3Duser password=3Dpass';</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">-- connect to remote database</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">PERFORM 'SELECT dblink_connect(''con'', =
v_constr);';</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">RAISE NOTICE 'connected';</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">FOR v_config in (SELECT * from&nbsp; dblink('''con''', =
'SELECT * from config ') AS</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">&nbsp; hc(id character(36), name text)) </FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">LOOP</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">INSERT INTO config (id, name) values (v_config.id, =
v_config.name);</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">END LOOP;</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">PERFORM 'SELECT dblink_disconnect (''con'');';</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">v_return :=3D 4;</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">RETURN v_return;</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2 =
FACE=3D"Arial">END;</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">$$ LANGUAGE 'plpgsql';</FONT>
</P>
<BR>

<P><FONT SIZE=3D2 FACE=3D"Arial">But now I get:</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">NOTICE:&nbsp; connected</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">ERROR:&nbsp; could not establish =
connection</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">DETAIL:&nbsp; missing &quot;=3D&quot; =
after &quot;'con'&quot; in connection info string</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">CONTEXT:&nbsp; PL/pgSQL function =
&quot;im****t_sc&quot; line 13 at FOR over SELECT rows</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">********** Fehler **********</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">ERROR: could not establish =
connection</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">SQL Status:08001</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Detail:missing &quot;=3D&quot; after =
&quot;'con'&quot; in connection info string</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Kontext:PL/pgSQL function =
&quot;im****t_sc&quot; line 13 at FOR over SELECT rows</FONT>
</P>
<BR>

<P><FONT SIZE=3D2 FACE=3D"Arial">What does that mean?</FONT>
</P>

<P><FONT SIZE=3D2 FACE=3D"Arial">Thank you very much.</FONT>

<BR><FONT SIZE=3D2 FACE=3D"Arial">Tobias</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C8E349.3BCEB1EB--
 




 1 Posts in Topic:
Dataimport from remote db
tobias.schoenit@[EMAIL PR  2008-07-11 13:28:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 5:25:13 CST 2008.