Hello, i'm trying to make a TRIGGER in ORACLE using ORACLE SQL DEVELOPER, I would check that the dates entered as start date reservation to reservation date or date of a service charge will be equal to or greater than the current date is inserted in the record.
these are the fields in my table
Service (date_service, cost_variation, number_room, id_service);
this is my code:
CREATE OR REPLACE TRIGGER VERIFY_DATE
BEFORE INSERT OR UPDATE OF FECHA_PLAN ON SERVICE
FOR EACH ROW
DECLARE
fecha_ac DATE;
BEGIN
SELECT SYSDATE INTO fecha_ac FROM DUAL;
IF(:NEW.FECHA_PLAN > fecha_ac)THEN
dbms_output.put_line('The date of the plan should be more than the current date ');
raise_application_error(-20601, 'Dato invalido');
END IF;
END;
and this is the error I get when trying to run the TRIGGER
INSERT INTO "MIGRARBD"."SERVICE"
(date_service, cost_variation, number_room, id_service)
VALUES
(TO_DATE('20/01/10', 'DD/MM/RR'), '2', '1', '1')
There was an error when saving changes to table "MIGRARBD"."SERVICE":
Fila 1: ORA-20601: Dato invalido
ORA-06512: en "MIGRARBD.VERIFICAR_FECHA", línea 7
ORA-04088: error during execution of trigger 'MIGRARBD.VERIFICAR_FECHA'
ORA-06512: on line 1
I hope you can help ... and excuse my English