getting number of affected rows in dblink_exec - Mailing list pgsql-general

From Stefano Salvador
Subject getting number of affected rows in dblink_exec
Date
Msg-id cf192dd0805200334h139888e0t8e358f557b399a65@mail.gmail.com
Whole thread Raw
List 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

pgsql-general by date:

Previous
From: Maarten Deprez
Date:
Subject: escaping and quoting
Next
From: Kevin Hunter
Date:
Subject: Re: i am looking for postgresql hosting server