The questions can come in any order, so make sure you are selecting right option for all questions.
1. Create a trigger named 'trigger_slab_insert' that is triggered whenever a slab record is added in the slab table. This trigger will insert the id,from_unit, to_unit, rate and action into the table 'slab_log_history' after the insertion of records into the slab table. The action name in the affected log table 'slab_log_history' is "Insert_Slab". Hints: Trigger name : trigger_slab_insert Table name : slab_log_history Field names : id,from_unit,to_unit,rate,action Action : 'Insert_Slab'.
create or replace trigger trigger_slab_insert after insert on slab for each row begin insert into slab_log_history values(:new.id, :new.from_unit, :new.to_unit, :new.rate ,'Insert_Slab'); end; /
2. Create a trigger named 'trigger_electricity_conn_type' that is triggered whenever a electricity connection type record is added in the electricity_connection_type table. This trigger will insert the id, connection_name and action into the table 'electricity_conn_type_log' after the insertion of records into the electricity_connection_type table. The action name in the affected log table 'electricity_conn_type_log' is "Insert_Electricity_Connection_Type". Hints: Trigger name : trigger_electricity_conn_type Table name : electricity_conn_type_log Field names : id,connection_name,action Action : 'Insert_Electricity_Connection_Type'.
create or replace trigger trigger_electricity_conn_type after insert on electricity_connection_type for each row begin insert into electricity_conn_type_log values(:new.id,:new.connection_name,'Insert_Electricity_Connection_Type'); end; /
3. Create a trigger named 'trigger_building_type_insert' that is triggered whenever a building type record is added in the building_type table. This trigger will insert the id, connection_type_id, name and action into the table 'building_type_log_history' after the insertion of records into the building_type table. The action name in the affected log table 'building_type_log_history' is "Insert_Building_Type". Hints: Trigger name : trigger_building_type_insert Table name : building_type_log_history Field names : id,connection_type_id,name,action Action : 'Insert_Building_Type'
create or replace trigger trigger_building_type_insert after insert on building_type for each row begin insert into building_type_log_history values(:new.id,:new.connection_type_id,:new.name,'Insert_Building_Type'); end; /
4. Create a trigger named 'trigger_building_bf_update' that is triggered whenever the building table is updated. This trigger will insert the id,contact_number and action into the table 'building_log_history' before the updation of building details. The action name in the affected log table building_log_history is 'Before_Update_Building'. Hints: Trigger name : trigger_building_bf_update Table name : building_log_history Field names : id,contact_number,action Action : 'Before_Update_Building'
create or replace trigger trigger_building_bf_update before update on building for each row begin insert into building_log_history values(:old.id,:old.contact_number,'Before_Update_Building'); end; /
5. Create a trigger named 'trigger_meter_af_update' that is triggered whenever the meter table is updated. This trigger will insert the id,meter_number and action into the table 'meter_log_history' after the updation of meter details. The action name in the affected log table meter_log_history is 'After_Update_Meter'. Hints: Trigger name : trigger_meter_af_update Table name : meter_log_history Field names : id,meter_number,action Action : 'After_Update_Meter'.
create or replace trigger trigger_meter_af_update after update on meter for each row begin insert into meter_log_history values(:new.id,:new.meter_number,'After_Update_Meter'); end; /
6. Create a trigger named 'trigger_building_type_bf' that is triggered whenever the building_type table is updated. This trigger will insert the id,name and action into the table 'building_update_log_history' before the updation of building type details. The action name in the affected log table building_update_log_history is 'Before_Update_Building_Type'. Hints: Trigger name : trigger_building_type_bf Table name : building_update_log_history Field names : id,name,action Action : 'Before_Update_Building_Type'.
create or replace trigger trigger_building_type_bf before update on building_type for each row begin insert into building_update_log_history values(:old.id,:old.name,'Before_Update_Building_Type'); end; /
7. Create a trigger named 'trigger_electricity_af_update' that is triggered whenever the electricity_reading table is updated. This trigger will insert the id,meter_id, total_units and action into the table 'electricity_reading_log' after the updation of electricity reading details. The action name in the affected log table electricity_reading_log_history is 'Af_Update_Electricity_Reading' Hints: Trigger name : trigger_electricity_af_update Table name : electricity_reading_log Field names : id,meter_id,total_units,action Action : 'Af_Update_Electricity_Reading'
create or replace trigger trigger_electricity_af_update after update on electricity_reading for each row begin insert into electricity_reading_log values(:new.id, :new.meter_id, :new.total_units, 'Af_Update_Electricity_Reading'); end; /
8. Create a trigger named 'trigger_bill_delete' that is triggered whenever a record in the bill table is deleted. This trigger will insert the id,meter_id, payable_amount and action into the table 'bill_log_history' after the deletion of bill details. The action name in the affected log table bill_log_history is 'After_Delete_Bill'. Hints: Trigger name : trigger_bill_delete Table name : bill_log_history Field names : id,meter_id, payable_amount,action Action : 'After_Delete_Bill'.
create or replace trigger trigger_bill_delete after delete on bill for each row begin insert into bill_log_history values(:old.id,:old.meter_id,:old.payable_amount,'After_Delete_Bill'); end; /
9. Create a trigger named 'trigger_slab_delete' that is triggered whenever a record in the slab table is deleted. This trigger will insert the id,from_unit, to_unit, rate and action into the table 'slab_log_history' after the deletion of slab details. The action name in the affected log table slab_log_history is 'After_Delete_Slab'. Hints: Trigger name : trigger_slab_delete Table name : slab_log_history Field names : id,from_unit,to_unit,rate,action Action : 'After_Delete_Slab'.
create or replace trigger trigger_slab_delete after delete on slab for each row begin insert into slab_log_history values(:old.id,:old.from_unit,:old.to_unit,:old.rate,'After_Delete_Slab'); end; /
10. Create a trigger named 'tr_electricity_reading_delete' that is triggered whenever a record in the electricity_reading table is deleted. This trigger will insert the id,meter_id, total_units and action into the table 'electricity_reading_log' after the deletion of electricity reading details. The action name in the affected log table electricity_reading_log_history is 'Af_Delete_Electricity_Reading'. Hints: Trigger name : tr_electricity_reading_delete Table name : electricity_reading_log Field names : id,meter_id, total_units,action Action : 'Af_Delete_Electricity_Reading'.
create or replace trigger tr_electricity_reading_delete after delete on electricity_reading for each row begin insert into electricity_reading_log values(:old.id,:old.meter_id,:old.total_units,'Af_Delete_Electricity_Reading'); end; /