Re: Creating Functions & Triggers

Поиск
Список
Период
Сортировка
От Markus Bertheau
Тема Re: Creating Functions & Triggers
Дата
Msg-id 1079861873.2085.1.camel@yarrow.bertheau.de
обсуждение исходный текст
Ответ на Creating Functions & Triggers  (Kevin Lohka <klohka@aboutfacedata.ab.ca>)
Ответы Re: Creating Functions & Triggers  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
В Сбт, 20.03.2004, в 23:33, Kevin Lohka пишет:
> Hello everyone, I'm new to creating functions & triggers on postgresql
> and am having trouble creating a trigger to update a record with the
> modification date and the current user.
>
> My code is below, but doesn't work.  It hangs psql when I attempt to
> modify the record.  The function and trigger are created successfully.
>
> CREATE FUNCTION email_mod_date() RETURNS OPAQUE AS '
>    BEGIN
>          UPDATE email SET  m_date = current_date, m_by_user =
> current_user
>          WHERE id = NEW.id;
>
>    RETURN NULL;
>    END;
> 'LANGUAGE 'plpgsql';
>
>
>
> CREATE TRIGGER email_mod_date
> AFTER UPDATE
> ON email
> FOR EACH ROW
> EXECUTE PROCEDURE email_mod_date();

The trigger is probably recursively being called.
http://www.postgresql.org/docs/current/static/triggers.html#TRIGGER-DEFINITION

--
Markus Bertheau <twanger@bluetwanger.de>


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

Предыдущее
От: Kevin Lohka
Дата:
Сообщение: Re: Creating Functions & Triggers
Следующее
От: Mihai Tanasescu
Дата:
Сообщение: Simple list tables question