Skip to content

Instantly share code, notes, and snippets.

@wyanez
Created June 29, 2012 15:02
Show Gist options
  • Save wyanez/3018466 to your computer and use it in GitHub Desktop.
Save wyanez/3018466 to your computer and use it in GitHub Desktop.
[PLPGSQL] Evitar el borrado de registros en una tabla de postgres
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();
@alconor
Copy link

alconor commented Feb 4, 2021

Excelente ayuda amigo!
Me funcionó a la perfección.
Saludos!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment