Re: Use of delete...returning in function problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: Bart Degryse <Bart(dot)Degryse(at)indicator(dot)be>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Use of delete...returning in function problem
Date: 2007-09-04 15:55:05
Message-ID: 25973.1188921305@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Richard Huxton <dev(at)archonet(dot)com> writes:
> I think it's just the brackets () - plpgsql's parser isn't terribly
> sophisticated.

It's not plpgsql's fault --- you'll get the same result if you put
parentheses around a DELETE command at the SQL command line.

regression=# (delete from fool);
ERROR: syntax error at or near "delete"
LINE 1: (delete from fool);
^

The OP may be used to putting parens into his FOR loops because it
works with SELECT:

regression=# (select * from zz1);
f1 | f2 | f3
----+----+----
(0 rows)

The difference is that SELECT can be put into larger groupings (eg
UNIONs) so it has to be parenthesiz-able. If we ever considered
supporting DELETE RETURNING as a component of larger queries, this
syntax difference would likely go away.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Ray 2007-09-04 15:56:04 Re: How to influence the planner
Previous Message PostgreSQL Admin 2007-09-04 15:27:32 Re: Trigger to change different row in same table