25.3.6.3 Adding Events Using a Trigger
Use a trigger to log status or schedule changes as lifecycle events.
When an FRC_PATIENT_PROCEDURES row is updated, it compares the
:NEW.STATUS and :OLD.STATUS to decide if the
status has changed. If so, it uses "STATUS" for the event type. If
instead the procedure's date, doctor, or duration in hours changes, then the event type
is "SCHEDULE". If either case occurs, then it calls
ADD_EVENT in the FRC_PROCEDURE_LIFECYCLE package
to do that.
trigger frc_patient_procedures_au
after update on frc_patient_procedures
for each row
declare
l_event_type varchar2(80);
begin
if :new.status != :old.status then
l_event_type := 'STATUS';
elsif :new.procedure_date != :old.procedure_date
or :new.doctor != :old.doctor
or :new.duration_hours != :old.duration_hours then
l_event_type := 'SCHEDULE';
end if;
if l_event_type is not null then
frc_procedure_lifecycle.add_event(:new.id, l_event_type);
end if;
end;Parent topic: Notifying Workflow of Data Changes