Can we use dblink for insert and update of dynamic values

From: Jenish Vyas <jenishvyas(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Can we use dblink for insert and update of dynamic values
Date: 2011-08-18 14:26:38
Message-ID: CANqFkjGstCe-vArzn+c2X8ghRaZG1=ERwO2cHspXr9hJ1O10wQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi All,

Can we user dblink for insert and update of dynamic values??

Sample function :

CREATE OR REPLACE FUNCTION dblink_test()
RETURNS boolean AS
$BODY$
DECLARE
v1 numeric;
v2 character varying(50);
BEGIN
v1 := 123; v2 := 'asdasdasd';
select dblink_exec('dbname=testing_db_link_1'::text, 'insert into abc
values(v1,v2);'::text);
select dblink_exec('dbname=testing_db_link_1'::text, 'update abc set b = ''
testing '' where a = v1;'::text);
RETURN FALSE;
END;
$BODY$
LANGUAGE plpgsql STABLE
COST 100;

When I am running this function it is giving me following error..

ERROR: column "v1" does not exist
SQL state: 42703
Context: Error occurred on dblink connection named "unnamed": could not
execute command.
SQL statement "select dblink_exec('dbname=testing_db_link_1'::text, 'insert
into abc values(v1,v2);'::text)"
PL/pgSQL function "aaa" line 9 at SQL statement

Plz. guide me.

Thanks & regards,
JENISH VYAS

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ireneusz Pluta 2011-08-18 15:16:51 Re: Can we use dblink for insert and update of dynamic values
Previous Message Nicholson, Brad (Toronto, ON, CA) 2011-08-18 14:08:44 Re: max_stack_depth error, need suggestion