Last active
December 1, 2015 06:26
-
-
Save yogonza524/93e3f800dc3d30ea74d9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-- Function: public.update_config() | |
-- DROP FUNCTION public.update_config(); | |
CREATE OR REPLACE FUNCTION public.update_config() | |
RETURNS trigger AS | |
$BODY$ | |
DECLARE | |
output integer; | |
BEGIN | |
IF (NEW.dia_emision < 1 OR NEW.dia_emision > 31) THEN | |
NEW.dia_emision = 1; | |
END IF; | |
IF (NEW.dia_vencimiento < 1 OR NEW.dia_vencimiento > 31) THEN | |
NEW.dia_vencimiento = 15; | |
END IF; | |
IF (NEW.id <> OLD.id) THEN | |
NEW.id = OLD.id; | |
END IF; | |
NEW.fecha_ultima_modificacion = now(); | |
RETURN NEW; | |
END; | |
$BODY$ | |
LANGUAGE plpgsql VOLATILE | |
COST 100; | |
ALTER FUNCTION public.update_config() | |
OWNER TO postgres; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
La clave generada es unica y no se puede modificar, si se quiere hacerlo se vuelve siempre al valor anterior (generado solo por el trigger)