Feature Idea: Statement Echo in DO$$

From: David Johnston <polobo(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Feature Idea: Statement Echo in DO$$
Date: 2013-07-03 19:32:35
Message-ID: 1372879955610-5762454.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am using a DO$$ $$ block to emulate something that admittedly may be
standard practice to accomplish using psql but for which I am using a less
capable UI.

Anyway, the basic form is:

DO $$
DECLARE some_var varchar := 'value';
BEGIN

UPDATE ..... WHERE col = some_var;
UPDATE ..... WHERE col = some_var;

RETURN;
END;
$$

Now because of the DO I have no idea how many records were affected for each
of the UPDATE statements. I am thinking that, either at the statement-level
or even somehow defined inside the DO, some way to have the system
automatically echo the usual "0 records updated" message out of the DO.

i.e., UPDATE (VERBOSE) .... SET id = some_var;

GET DIAGNOSTICS obviously works, and for a stored function is probably the
better option, but for a simple DO oriented script command it is quite
verbose.

There is a prior discussion (somewhere) regarding using STRICT without
RETURNING in similar situations to easily define when only one (and only
one) record is expected to be affected. This thought falls into the same
usability category.

Thoughts?

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/Feature-Idea-Statement-Echo-in-DO-tp5762454.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Carville 2013-07-03 20:11:35 Cannot connect to remote postgres database
Previous Message Daniel Serodio (lists) 2013-07-03 17:39:46 AWS, cascading replication and WAL archiving