1

tenego que crear un disparador y me da este error

Trigger FECHASER compilado

Errores: comprobar log de compilador

Se trata de crear un disparador que impida que se modifique la tuplas fecha de una tabla y si inserto un parte en esa tabla respete una serie de condiciones

si intento modificar la fecha me da un error -20401

si la fecha es posterior a hoy me pone la fecha de hoy en el parte

si la fecha es anterior al lunes de esta semana me dara un error -20402 mi idea es esta

CREATE OR REPLACE TRIGGER FECHASER BEFORE
    INSERT OR UPDATE of fecha on partes for each row
declare
PRAGMA AUTONOMOUS_TRANSACTION;
begin
    if updating then
    raise_application_error(-20401,'prohibido modificar la fecha del un parte de trabajo');
    end if;
    if inserting and TRUNC(fecha)> trunc(sysdate) then 
    update partes set fecha = sysdate
    where TRUNC(fecha)> trunc(sysdate);
    dbms_output.put_line('el parte se ha grabado con fecha de hoy');
    if inserting and (trunc(sysdate) - trunc(last_day(sysdate,'lunes'))<7) then
    raise_application_error(-20402,'lafecha debe ser entre el pasado lunes y hoy');
    end if;
END;
/

Esta bien el disparador? porque me da ese error?

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.