Re: [Fwd: Re: Trigger Procedures] - Mailing list pgsql-novice

From Stephan Szabo
Subject Re: [Fwd: Re: Trigger Procedures]
Date
Msg-id 20050513071811.T97417@megazone.bigpanda.com
Whole thread Raw
In response to [Fwd: Re: Trigger Procedures]  (Steve Tucknott <steve@retsol.co.uk>)
List pgsql-novice
On Thu, 13 May 2005, Steve Tucknott wrote:

> Maybe I can explain a bit better.
> We have a generic procedure that takes table names, record numbers and
> text and then creates an audit. There is a trigger automatically created
> for each table that needs to be audited. Under Informix (this is a
> legacy procedure that is being converted), I can pass NEW into the
> generic function - so I can have different 'named' fields being passed.
> In the generic function the names of the passed fields (ie the variable
> names) becomes static. IE if the trigger is on table A I pass field A,
> if on table B I pass field B (both being same data type). In the generic
> procedure this passed parameter is mapped to a variable called
> 'inputField'. So my procedure doesn't have to worry that in reality
> inputField is field A or field B and I can use simple statements like
> INSERT INTO auditTable VALUES(inputField.......
> Using PostGreSQL (7.4.5) it appear that I cannot pass NEW fields into
> the generic function - so it means that the function has to become
> 'aware' of the source. IE the procedure now has to do 'if the trigger
> source table is table A then use NEW.fieldA ...... if the trigger source
> table is table B then use NEW.fieldB ...... etc'.

Some of the PLs (not plpgsql) allow indirect references via field name
which might allow you to pass the name of field as the trigger argument.
That might be a good fit for what you are doing at the cost of having to
use one of the other languages.

pgsql-novice by date:

Previous
From: John DeSoi
Date:
Subject: Re: Starting the Database
Next
From: D.C.
Date:
Subject: nope, still no history ..