-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- TRIGGER BEFORE INSERT
-- Tabla: sga_certificados
-- Version 3.0.0
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

-- DROP FUNCTION ftib_sga_certificados();
CREATE OR REPLACE FUNCTION ftib_sga_certificados() RETURNS TRIGGER AS $BODY$
  BEGIN
	   -- Genera un registro en la tabla de entidades..
       NEW.entidad := f_generar_entidad(250);
       RETURN NEW;
  END;
$BODY$ LANGUAGE plpgsql;


-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- Trigger de INSERT sobre sga_certificados
-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-- DROP TRIGGER tib_sga_certificados  ON sga_certificados RESTRICT;;
CREATE TRIGGER tib_sga_certificados 
    BEFORE INSERT ON sga_certificados
    FOR EACH ROW EXECUTE PROCEDURE ftib_sga_certificados();
