Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id B19379F9604 for ; Sun, 12 Aug 2007 08:33:49 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 26575-02 for ; Sun, 12 Aug 2007 08:33:44 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id A2C779F95FE for ; Sun, 12 Aug 2007 08:33:48 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 89D6F3141A; Sun, 12 Aug 2007 13:33:45 +0200 (MET DST) Date: Sun, 12 Aug 2007 07:33:42 -0400 From: Lew User-Agent: Thunderbird 2.0.0.5 (X11/20070719) MIME-Version: 1.0 X-Newsgroups: pgsql.general Subject: Re: Trigger Procedure Error: NEW used in query that is not in a rule References: <86d227fd0708110043q341a2908q67e87570bca89492@mail.gmail.com> In-Reply-To: <86d227fd0708110043q341a2908q67e87570bca89492@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4t6dnWfG99WKbSPbnZ2dnUVZ_hadnZ2d@comcast.com> Lines: 26 X-Usenet-Provider: http://www.giganews.com X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.35 To: pgsql-general@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/1050 X-Sequence-Number: 118899 Javier Fonseca V. wrote: > Hello. > > I'm doing a Trigger Procedure in pl/pgSQL. It makes some kind of auditing. > > I think that it's working alright except for the next line: > > EXECUTE 'INSERT INTO ' || quote_ident(somedynamictablename) || ' SELECT > new.*'; > > PostgreSQL keeps telling me: "ERROR: NEW used in query that is not in a > rule". I think that this NEW problem is because of the scope of the > EXECUTE statement (outside the scope of the trigger), so it doesn't > recognize the NEW record. > > Maybe I could fix it concatenating column names and the 'new' values but > I want to do my trigger as flexible as possible (I have several tables > to audit). > > Somebody has any suggestion? You got some suggestions in response to your multipost of this question in pgsql.sql. -- Lew