Social Icons

lunes, 13 de noviembre de 2017

SUMAR VARIOS CAMPOS A TRAVÉS DE UN TRIGGER

TABLA DE UNA ENTIDAD ESPACIAL DE UNA GEODATABASE

Antecedentes:
Tengo una tabla con varios campos de preguntas, las cuales tienen un cierto numero, quiero que al ingresar estos valores se calcule automáticamente la suma, buscando la mejor solución es con un trigger:


create or replace TRIGGER GISRRHH.RRHH_SUMACR
    BEFORE INSERT OR UPDATE ON GISRRHH.EVALUACION
    FOR EACH ROW
BEGIN
    
    :new.SUMACALIFICACIONCR := nvl(:new.PREGUNTARCR1,0) + nvl(:new.PREGUNTARCR2,0) +nvl(:new.PREGUNTARCR3,0) +nvl(:new.PREGUNTARCR4,0) +nvl(:new.PREGUNTARCR5,0) 
    +nvl(:new.PREGUNTARCR6,0) +nvl(:new.PREGUNTARCR7,0) + nvl(:new.PREGUNTARCR8,0) ; 
    
       :new.SUMACALIFICACIONEYF := nvl(:new.PREGUNTAREF1,0) + nvl(:new.PREGUNTAREF2,0) +nvl(:new.PREGUNTAREF3,0) +nvl(:new.PREGUNTAREF4,0) +nvl(:new.PREGUNTAREF5,0) 
    +nvl(:new.PREGUNTAREF6,0)  ; 
END;


La funcion nvl, convierto los valores nulos en 0

No hay comentarios.:

Publicar un comentario

Data Analyzer Error Excel

Error en copiar las celdas no se abre el Excel:  Haz clic en YES (Sí) en el mensaje de error y busca manualmente el archivo EXCEL.exe. Depen...

 
 
Blogger Templates