can a trigger on insert -> update other tables?

Поиск
Список
Период
Сортировка
От will trillich
Тема can a trigger on insert -> update other tables?
Дата
Msg-id 20010302151319.B26218@mail.serensoft.com
обсуждение исходный текст
Ответы Re: can a trigger on insert -> update other tables?
Список pgsql-general
i've got a "_rating" table that, when a new record is added,
i'd like to have propagate through some other tables to update
running totals:

CREATE FUNCTION _rating_propagate( _rating ) RETURNS OPAQUE AS '
    DECLARE

        n ALIAS FOR $1;
        opinion   char(1) := upper(substring(n.rating from 1 for 1));

    BEGIN

        UPDATE sometable  SET fld = fld + 1 WHERE id = .... ;
        UPDATE othertable SET fld = fld + 1 WHERE id = .... ;
    [yada yada]
    END;
' LANGUAGE 'plpgsql';

CREATE TRIGGER _rating_propagate
    BEFORE INSERT ON _rating
    FOR EACH ROW EXECUTE PROCEDURE _rating_propagate( NEW );

INSERT INTO _rating VALUES ( ... );

the insert into _rating works fine, but none of the other tables
are actually UPDATED. who's got the clue stick?

--
will@serensoft.com
http://www.dontUthink.com/

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

Предыдущее
От: will trillich
Дата:
Сообщение: Re: how to examin the database structure with an sql command
Следующее
От: adb
Дата:
Сообщение: Can you list the text of a proc in psql?