Last active
October 3, 2015 02:28
-
-
Save longkey1/2372566 to your computer and use it in GitHub Desktop.
The function for making it move to a deleted table.
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
CREATE OR REPLACE FUNCTION process_deleted() RETURNS TRIGGER AS $$ | |
BEGIN | |
IF (TG_OP = 'DELETE') THEN | |
EXECUTE 'INSERT INTO deleted_' || TG_RELNAME || ' VALUES(($1).*)' USING OLD; | |
RETURN OLD; | |
END IF; | |
RETURN NULL; | |
END; | |
$$ LANGUAGE plpgsql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment