Trigger Procedure Error: NEW used in query that is not in a rule

From: "Javier Fonseca V(dot)" <fonsecajavier(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Trigger Procedure Error: NEW used in query that is not in a rule
Date: 2007-08-11 07:45:09
Message-ID: 86d227fd0708110045t16e39442xd35746eb59296362@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2007-08-11 08:16:47 Re: Trigger Procedure Error: NEW used in query that is not in a rule
Previous Message Javier Fonseca V. 2007-08-11 07:43:30 Trigger Procedure Error: NEW used in query that is not in a rule

Browse pgsql-sql by date

  From Date Subject
Next Message Pavel Stehule 2007-08-11 08:16:47 Re: Trigger Procedure Error: NEW used in query that is not in a rule
Previous Message Javier Fonseca V. 2007-08-11 07:43:30 Trigger Procedure Error: NEW used in query that is not in a rule