Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id BEAF69FA163 for ; Tue, 4 Sep 2007 12:55:15 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 76620-06 for ; Tue, 4 Sep 2007 12:55:10 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 4371D9FA15A for ; Tue, 4 Sep 2007 12:55:10 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l84Ft5XR025974; Tue, 4 Sep 2007 11:55:06 -0400 (EDT) To: Richard Huxton cc: Bart Degryse , pgsql-sql@postgresql.org Subject: Re: Use of delete...returning in function problem In-reply-to: <46DD373E.1080308@archonet.com> References: <46DD3B8E.A3DD.0030.0@indicator.be> <46DD373E.1080308@archonet.com> Comments: In-reply-to Richard Huxton message dated "Tue, 04 Sep 2007 11:45:18 +0100" Date: Tue, 04 Sep 2007 11:55:05 -0400 Message-ID: <25973.1188921305@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/39 X-Sequence-Number: 29252 Richard Huxton 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