tww
.tww_app
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
ft_vw_tww_maintenance_event_update()
Parameters
Name
Type
Mode
IN
Definition
DECLARE BEGIN UPDATE tww_od.maintenance_event SET base_data = NEW.base_data , cost = NEW.cost , data_details = NEW.data_details , duration = NEW.duration , fk_dataowner = NEW.fk_dataowner , fk_measure = NEW.fk_measure , fk_operating_company = NEW.fk_operating_company , fk_provider = NEW.fk_provider , identifier = NEW.identifier , last_modification = NEW.last_modification , operator = NEW.operator , reason = NEW.reason , remark = NEW.remark , result = NEW.result , status = NEW.status , time_point = NEW.time_point WHERE obj_id = OLD.obj_id; IF OLD.maintenance_event_type <> NEW.maintenance_event_type THEN RAISE EXCEPTION 'Type change not allowed for maintenance_event' USING HINT = 'You cannot switch from ' || OLD.maintenance_event_type || ' to ' || NEW.maintenance_event_type; END IF; CASE WHEN NEW.maintenance_event_type = 'bio_ecol_assessment'::tww_app.maintenance_event_type THEN UPDATE tww_od.bio_ecol_assessment bio_ecol_assessment SET obj_id = OLD.obj_id , comparison_last = NEW.ba_comparison_last , date_last_examen = NEW.ba_date_last_examen , impact_auxiliary_indic = NEW.ba_impact_auxiliary_indic , impact_external_aspect = NEW.ba_impact_external_aspect , impact_macroinvertebrates = NEW.ba_impact_macroinvertebrates , impact_water_plants = NEW.ba_impact_water_plants , intervention_demand = NEW.ba_intervention_demand , io_calculation = NEW.ba_io_calculation , kind_water_body = NEW.ba_kind_water_body , outlet_pipe_clear_height = NEW.ba_outlet_pipe_clear_height , q347 = NEW.ba_q347 , relevance_matrix = NEW.ba_relevance_matrix , relevant_slope = NEW.ba_relevant_slope , surface_water_bodies = NEW.ba_surface_water_bodies , water_specific_discharge_freight_nh4_n_current = NEW.ba_water_specific_discharge_freight_nh4_n_current , water_specific_discharge_freight_nh4_n_current_opt = NEW.ba_water_specific_discharge_freight_nh4_n_current_opt , water_specific_discharge_freight_nh4_n_planned = NEW.ba_water_specific_discharge_freight_nh4_n_planned WHERE obj_id = OLD.obj_id; WHEN NEW.maintenance_event_type = 'examination'::tww_app.maintenance_event_type THEN UPDATE tww_od.examination examination SET obj_id = OLD.obj_id , equipment = NEW.ex_equipment , fk_reach_point = NEW.ex_fk_reach_point , from_point_identifier = NEW.ex_from_point_identifier , inspected_length = NEW.ex_inspected_length , recording_type = NEW.ex_recording_type , to_point_identifier = NEW.ex_to_point_identifier , vehicle = NEW.ex_vehicle , videonumber = NEW.ex_videonumber , weather = NEW.ex_weather WHERE obj_id = OLD.obj_id; WHEN NEW.maintenance_event_type = 'maintenance'::tww_app.maintenance_event_type THEN UPDATE tww_od.maintenance maintenance SET obj_id = OLD.obj_id , kind = NEW.mn_kind WHERE obj_id = OLD.obj_id; ELSE RAISE NOTICE 'vw_tww_maintenance_event type not known (%)', NEW.maintenance_event_type; -- ERROR END CASE; RETURN NEW; END;