getting number of affected rows in dblink_exec

From: "Stefano Salvador" <stefano(dot)salvador(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: getting number of affected rows in dblink_exec
Date: 2008-05-20 10:34:12
Message-ID: cf192dd0805200334h139888e0t8e358f557b399a65@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

In my db I have created a view that read data from a remote table
using dblink, I can modify the remote table using a couple of rules on
the view. My problem arise when I try to get the number of affected
rows since dblink_exec returns such information in a result set
instead of putting it in the return value.

Here is the relevant (simplified) sql code:

CREATE VIEW test_view AS
SELECT test.id, test.description
FROM dblink('dbname=xxx port=5432 host=xxx user=xxx
password=xxx'::text, 'select id, description'::text) test_view(id
integer, description character varying(100));

CREATE RULE test_view_upd AS
ON UPDATE TO test_view DO INSTEAD
SELECT dblink_exec('dbname=xxx port=5432 host=xxx user=xxx password=xxx',
'update test set description = '''::text || NEW.description || '''
where id = ' || old.id) AS dblink_exec;

there is a way to create this rule in a way compatible with the
standard SQL behaviour ?

Thanks in advance,

Stefano

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Hunter 2008-05-20 11:11:47 Re: i am looking for postgresql hosting server
Previous Message glene77is 2008-05-20 10:19:20 Re: rounding problems