passing parameters to a trigger function

Поиск
Список
Период
Сортировка
От Larry White
Тема passing parameters to a trigger function
Дата
Msg-id d15ea14a0603210621p6229a81cs5bcdbaa6085c5c5c@mail.gmail.com
обсуждение исходный текст
Ответы Re: passing parameters to a trigger function  (Martijn van Oosterhout <kleptog@svana.org>)
Re: passing parameters to a trigger function  (Terry Lee Tucker <terry@esc1.com>)
Re: passing parameters to a trigger function  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Список pgsql-general
I can't figure out how to pass parameters to a trigger function. 
I checked the documentation and saw that trigger functions don't take params in the usual fashion, 
but couldn't find an example of a pl-sql trigger function that used the original row data within the function.

What I want is an on update trigger that creates an entry in a second table. The second (history) table has a subset of the columns in the first.

Here's what I have so far:

-- THIS IS WRONG - CANT PASS PARAMS INTO TRIGGER FUNCTION

CREATE OR REPLACE FUNCTION audit_task ("param type declarations were here") RETURNS TRIGGER AS '
-- create an audit trail record
BEGIN
-- Perform the insert

INSERT INTO TASK_h (id,
updated_by,
updated,
name,
description
)
VALUES ($1, $2, $3, $4, $5);

RETURN NULL;
END;

' LANGUAGE plpgsql;


-- THE TRIGGER
CREATE TRIGGER t_audit_task AFTER INSERT OR UPDATE ON task FOR EACH ROW EXECUTE PROCEDURE audit_task();
So the question is, how do I access the row from the original table so I can perform the insert?

Thank you much.

В списке pgsql-general по дате отправления:

Предыдущее
От: Terry Lee Tucker
Дата:
Сообщение: Re: Order of Update - Second Try
Следующее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: passing parameters to a trigger function