Re: SQL Rule

Поиск
Список
Период
Сортировка
От Bert
Тема Re: SQL Rule
Дата
Msg-id 1146087328.537923.50290@u72g2000cwu.googlegroups.com
обсуждение исходный текст
Ответ на Re: SQL Rule  (Kenneth Downs <ken@secdat.com>)
Ответы Re: SQL Rule  (Alan Hodgson <ahodgson@simkin.ca>)
Re: SQL Rule  ("Bert" <clemens.bertschler@gmail.com>)
Список pgsql-general
Hi Kenneth
Thats exactly what i want, because we are running more selects than
inserts, and therefore a view is not the best way to go.
But I still have a problem, I was doing like you told me.
I have still the same table (without the rules definition)
So I created a trigger function:

CREATE FUNCTION trigger_test()
    RETURNS TRIGGER
    AS 'BEGIN
        new.c = (new.a + new.b);
        RETURN new;
    END;'
LANGUAGE 'plpgsql';

and then the Trigger:

CREATE TRIGGER trigger_sum
    AFTER INSERT OR UPDATE
    ON test
    FOR EACH ROW
    EXECUTE PROCEDURE trigger_test();

The inserting and updating is doing well, but its not summing up the a
and b and save it to the c column. So far maybe you can help me second
time.
Thanks,
Bert


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

Предыдущее
От: Eduardo Muñoz
Дата:
Сообщение: Problem with copy
Следующее
От: Alan Hodgson
Дата:
Сообщение: Re: SQL Rule