Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 4C5799F973E for ; Sat, 11 Aug 2007 04:43:35 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 93041-04 for ; Sat, 11 Aug 2007 04:43:31 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.245]) by postgresql.org (Postfix) with ESMTP id C6F509F973D for ; Sat, 11 Aug 2007 04:43:31 -0300 (ADT) Received: by an-out-0708.google.com with SMTP id c36so169769ana for ; Sat, 11 Aug 2007 00:43:30 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; b=VWBLgfMJBsy1h4ju2Q1DyIHI4oFCIU28z818sdK0fhM3m+I4vLitRQmbSdLVZv6kkL7di5j7s/+T1Y4nLQ4etRmpYBAGOyT2QoJhNnwGrI7FDaueEpadJDws02cxYLoCtcE6LMFocaOFc7PYuJdeo+WhYo+DHZP0U6X9AWu96G4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=hZ1mfwUlL82toBiyG1yo2I5i5gbIPA70VDmYPSwRVDo5Fsd7dfl64y8lffjrTCUlEZbSnB306zjY/P8XAhKQXNXFXtlDX/OCebUwfSvfpl0rC2lGs0UYEldg+sjWog8N8mCk7ria2n0udLZ1n+hgHFyQ0Gx/DVab6MTNqBKHtYI= Received: by 10.100.163.17 with SMTP id l17mr1845816ane.1186818210115; Sat, 11 Aug 2007 00:43:30 -0700 (PDT) Received: by 10.100.137.3 with HTTP; Sat, 11 Aug 2007 00:43:30 -0700 (PDT) Message-ID: <86d227fd0708110043q341a2908q67e87570bca89492@mail.gmail.com> Date: Sat, 11 Aug 2007 02:43:30 -0500 From: "Javier Fonseca V." To: pgsql-general@postgresql.org Subject: Trigger Procedure Error: NEW used in query that is not in a rule MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_39499_11766379.1186818210022" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/564 X-Sequence-Number: 118413 ------=_Part_39499_11766379.1186818210022 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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? Thanks a lot, Javier ------=_Part_39499_11766379.1186818210022 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline

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?

Thanks a lot,

Javier

------=_Part_39499_11766379.1186818210022--