Re: [Fwd: Re: Trigger Procedures]

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: [Fwd: Re: Trigger Procedures]
Дата
Msg-id 20050513071811.T97417@megazone.bigpanda.com
обсуждение исходный текст
Ответ на [Fwd: Re: Trigger Procedures]  (Steve Tucknott <steve@retsol.co.uk>)
Список 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 по дате отправления:

Предыдущее
От: John DeSoi
Дата:
Сообщение: Re: Starting the Database
Следующее
От: D.C.
Дата:
Сообщение: nope, still no history ..