Re:[GENERAL] auditing question - PARTIALY SOLVED - Mailing list pgsql-general

From Bohdan.Linda
Subject Re:[GENERAL] auditing question - PARTIALY SOLVED
Date
Msg-id 1868.2830-30797-75430499-1184189640@seznam.cz
Whole thread Raw
In response to auditing question  (Bohdan.Linda <Bohdan.Linda@seznam.cz>)
List pgsql-general
Hello,

with help of Bricklen, I have found that the problem is the scope of call EXECUTE. When this is called it seems to be
"launched"outside of the trigger's scope and OLD/NEW is not defined. (Manual suggests it) 

The remaining question is how to compare OLD.* and NEW.* in generic way for 8.0.x version

Regards,
Bohdan

>
>     IF TG_OP = 'DELETE' THEN
>         EXECUTE 'INSERT INTO audit.' || TG_RELNAME ||
>                 ' SELECT _name, now(), OLD.*;';
>         RETURN OLD;
> =====================
>
> and binding the procedure to trigger AFTER INSERT,DELETE, UPDATE, gives me
> problem:
>
> ERROR:  NEW used in query that is not in a rule
> CONTEXT:  SQL statement "INSERT INTO audit.communities SELECT _name, now(),
> row(NEW);"

pgsql-general by date:

Previous
From: Rodrigo De León
Date:
Subject: Re: Count(*) throws error
Next
From: Tom Lane
Date:
Subject: Re: Count(*) throws error