[GENERAL] Trigger function problem - Mailing list pgsql-general

From Liglio Cavalcante
Subject [GENERAL] Trigger function problem
Date
Msg-id 1507145792892-0.post@n3.nabble.com
Whole thread Raw
List 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 by date:

Previous
From: Alban Hertroys
Date:
Subject: Re: [GENERAL] a JOIN to a VIEW seems slow
Next
From: "Frank Millman"
Date:
Subject: Re: [GENERAL] a JOIN to a VIEW seems slow