[GENERAL] Trigger function problem

Поиск
Список
Период
Сортировка
От Liglio Cavalcante
Тема [GENERAL] Trigger function problem
Дата
Msg-id 1507145792892-0.post@n3.nabble.com
обсуждение исходный текст
Список pgsql-general
Hi,

I am trying to migrate data from a master table to her partitions. I am
using an update trigger to delete and insert into the master table, and so
an insert trigger on the master table redirects the inserted registers to
the respective parrtition table. The problem is that the update trigger is
not deleting the registers from the master table. I am using postgresql 9.5.

CREATE OR REPLACE FUNCTION tb_master_update_trigger()
RETURNS TRIGGER AS $$
BEGINDELETE FROM tb_master WHERE OLD.id_master = id_master ;INSERT INTO tb_master VALUES (NEW.*); RETURN NULL;
END;
$$
LANGUAGE plpgsql;

CREATE TRIGGER update_tb_master_trigger BEFORE UPDATE ON tb_masterFOR EACH ROW EXECUTE PROCEDURE
tb_master_update_trigger();

UPDATE tb_master SET id_master = id_master ;



--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

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

Предыдущее
От: Alban Hertroys
Дата:
Сообщение: Re: [GENERAL] a JOIN to a VIEW seems slow
Следующее
От: "Frank Millman"
Дата:
Сообщение: Re: [GENERAL] a JOIN to a VIEW seems slow