Created
June 29, 2012 15:02
-
-
Save wyanez/3018466 to your computer and use it in GitHub Desktop.
[PLPGSQL] Evitar el borrado de registros en una tabla de postgres
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 proteger_datos() RETURNS TRIGGER AS $proteger_datos$ | |
DECLARE | |
BEGIN | |
-- | |
-- Esta funcion es usada para proteger datos en un tabla | |
-- No se permitira el borrado de filas si la usamos | |
-- en un disparador de tipo BEFORE / row-level | |
-- | |
RETURN NULL; | |
END; | |
$proteger_datos$ LANGUAGE plpgsql; | |
CREATE TRIGGER proteger_datos BEFORE DELETE | |
ON tabla FOR EACH ROW | |
EXECUTE PROCEDURE proteger_datos(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Excelente ayuda amigo!
Me funcionó a la perfección.
Saludos!