Last active
July 7, 2016 14:42
-
-
Save ruyjfs/f9891e95bc4e746aee5c67b3b8a558b3 to your computer and use it in GitHub Desktop.
Trigger to create copies on historical effects (Posgre SQL).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- INICIO - CATALOGOITEM - Criando FUNCTION E TRIGGER. | |
CREATE OR REPLACE FUNCTION catalogo.fn_h_catalogoitem() | |
RETURNS trigger LANGUAGE plpgsql | |
AS | |
'begin | |
INSERT INTO catalogo.h_catalogoitem | |
( | |
ctiid, ctinome, ctidsc, ctistatus, ctilinkreferencia, ctiitemrelacionado, ctlcod, grdid, gpiid, sgiid, apsid, undid, arqid, | |
ctidtcadastro, ctidtalteracao, usucpfcadastro, usucpfalteracao | |
) | |
VALUES | |
( | |
new.ctiid, | |
new.ctinome, | |
new.ctidsc, | |
new.ctistatus, | |
new.ctilinkreferencia, | |
new.ctiitemrelacionado, | |
new.ctlcod, | |
new.grdid, | |
new.gpiid, | |
new.sgiid, | |
new.apsid, | |
new.undid, | |
new.arqid, | |
new.ctidtcadastro, | |
new.ctidtalteracao, | |
new.usucpfcadastro, | |
new.usucpfalteracao | |
); | |
return new; | |
end;'; | |
CREATE TRIGGER tg_h_catalogoitem AFTER INSERT OR UPDATE | |
ON catalogo.catalogoitem FOR EACH ROW | |
EXECUTE PROCEDURE catalogo.fn_h_catalogoitem(); | |
-- FIM - CATALOGOITEM - Criando FUNCTION E TRIGGER. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment