Week10 - Triggers / Assess

The questions can come in any order, so make sure you are selecting right option for all questions.

1. Create a trigger named 'trigger_travel_card_af_update' that is triggered whenever the travel_card table is updated. This trigger will insert the id,person_name and action into the table 'travel_card_log_history' after the updation of travel card details. The action name in the affected log table travel_card_log_history is 'After_Update_Travel_Card'. Hints: Trigger name : trigger_travel_card_af_update Table name : travel_card_log_history Field names : id,person_name,action Action : 'After_Update_Travel_Card'.

create or replace trigger trigger_travel_card_af_update
after update on travel_card
for each row
begin
insert into travel_card_log_history
values(:new.id,:new.person_name,'After_Update_Travel_Card');
end;
/

2. Create a trigger named 'trigger_travel_payment_delete' that is triggered whenever a record in the travel_payment table is deleted. This trigger will insert the id,travel_card_id, amount and action into the table 'travel_payment_log_history' after the deletion of travel_payment details. The action name in the affected log table travel_payment_log_history is 'After_Delete_Travel_Payment'. Hints: Trigger name : trigger_travel_payment_delete Table name : travel_payment_log_history Field names : id,travel_card_id,amount,action Action : 'After_Delete_Travel_Payment'.

create or replace trigger trigger_travel_payment_delete
after delete on travel_payment
for each row
begin
insert into travel_payment_log_history
values(:old.id,:old.travel_card_id,:old.amount,'After_Delete_Travel_Payment');
end;
/

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.