Update trigger help

Поиск
Список
Период
Сортировка
От A Gilmore
Тема Update trigger help
Дата
Msg-id 435D1AEF.3070101@shaw.ca
обсуждение исходный текст
Ответы Re: Update trigger help  (A Gilmore <agilmore@shaw.ca>)
Список pgsql-novice
Hello,

I have a main table (t1), with several other tables referencing the ID
of t1.  When I update a row on t1 Id like to remove any rows that
reference it in the other tables.  The typical way of doing this Id
assume is using ON UPDATE trigger, which Ive written below.  Is this all
correct?  In the past Ive just been using plpgsql for returning rows in
which a VIEW wasn't sufficient, so Id like to just make sure Im doing
this correctly.

CREATE OR REPLACE FUNCTION t1_onUpdate() RETURNS NULL AS '
    DECLARE
    BEGIN
        id = NEW.id;
        DELETE FROM t2 WHERE t1_id = id;
        DELETE FROM t3 WHERE t1_id = id;
        DELETE FROM t4 WHERE t1_id = id;
        DELETE FROM t5 WHERE t1_id = id;
        DELETE FROM t6 WHERE t1_id = id;
    END;
'LANGUAGE plpgsql;

CREATE TRIGGER t1_onUpdate_trig BEFORE UPDATE ON t1
    FOR EACH ROW EXECUTE PROCEDURE t1_onUpdate();

Thank you in advance,
- A Gilmore

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

Предыдущее
От:
Дата:
Сообщение: Re: WinXP Install - Account Password Information
Следующее
От:
Дата:
Сообщение: PostgreSQL Database Server 8.0 Service Password Problem - WinXP Home