This is the first trigger that I'm making.
I'm trying to make a trigger to update only the field from the same row that is updated
when another field from the same row is updated. I'm doing something wrong.
Here is my code:
CREATE OR REPLACE TRIGGER MYSCH.APPT_RESCHEDULE
BEFORE UPDATE OF appointment
ON MYSCH.TBL_RESCHEDULE
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
BEGIN
if (
new.appointment >
ld.due_date) or ((trunc
new.appointment) = trunc
old.due_date))
and to_char
old.due_date,'HH24:MI:SS') < '13:00:00'))
and to_char
new.appointment,'HH24:MI:SS') = '08:00:00'
update tbl_reschedule
set :new.due_date = to_date(to_char
new.appointment,'DD-MON-YYYY')||' '|| '12:00:00',
'DDMON-YYYY HH24:MI:SS')
where pk_schedule_id :=
ld.pk_schedule_id;
else if (
new.appointment >
ld.due_date) or ((trunc
new.appointment) = trunc
old.due_date))
and to_char
old.due_date,'HH24:MI:SS') < '17:00:00'))
and to_char
new.appointment,'HH24:MI:SS') = '13:00:00'
update tbl_reschedule
set :new.due_date = to_date(to_char
new.appointment,'DD-MON-YYYY')||' '|| '17:00:00',
'DD-MON-YYYY HH24:MI:SS')
where pk_schedule_id :=
k_schedule_id;
end if;
EXCEPTION
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
NULL;
END MYSCH.APPT_RESCHEDULE;
Thank you for your help.
I'm trying to make a trigger to update only the field from the same row that is updated
when another field from the same row is updated. I'm doing something wrong.
Here is my code:
CREATE OR REPLACE TRIGGER MYSCH.APPT_RESCHEDULE
BEFORE UPDATE OF appointment
ON MYSCH.TBL_RESCHEDULE
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
BEGIN
if (
and to_char
and to_char
update tbl_reschedule
set :new.due_date = to_date(to_char
'DDMON-YYYY HH24:MI:SS')
where pk_schedule_id :=
else if (
and to_char
and to_char
update tbl_reschedule
set :new.due_date = to_date(to_char
'DD-MON-YYYY HH24:MI:SS')
where pk_schedule_id :=
end if;
EXCEPTION
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
NULL;
END MYSCH.APPT_RESCHEDULE;
Thank you for your help.