Re: trouble with triggers

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: trouble with triggers
Дата
Msg-id 001901c10ed5$a53c4d20$1001a8c0@archonet.com
обсуждение исходный текст
Ответ на trouble with triggers  ("Robert Treat" <robertt@auctionsolutions.com>)
Список pgsql-general
From: "Robert Treat" <robertt@auctionsolutions.com>

> CREATE TRIGGER formatname BEFORE update OR insert ON mytable FOR EACH row
> EXECUTE PROCEDURE lower(name);

> ERROR:  CreateTrigger: function lower() does not exist
>
> obviously this does exist, since I can do inserts/updates/selects using
> lower(). I have also tried creating my own version of a lower function but
> it gives me the same message.
>
> Am I missing something? This seems like it should be pretty
straightforward.
> tia,

You need a special function for triggers. It needs to return "opaque" type
and not take any parameters (in this case). Inside your new function you
will have something like:

BEGIN
  NEW.name := lower(NEW.name);
  RETURN NEW;
END;

Since you need to use NEW and OLD to affect what is happening during your
updates.

See the manuals for an example or http://techdocs.postgresql.org/ for
several.

- Richard Huxton


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

Предыдущее
От: Karel Zak
Дата:
Сообщение: Re: [HACKERS] Translators wanted
Следующее
От: "Robert Treat"
Дата:
Сообщение: RE: trouble with triggers