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.bo_comparison_last , date_last_examen = NEW.bo_date_last_examen , impact_auxiliary_indic = NEW.bo_impact_auxiliary_indic , impact_external_aspect = NEW.bo_impact_external_aspect , impact_macroinvertebrates = NEW.bo_impact_macroinvertebrates , impact_water_plants = NEW.bo_impact_water_plants , intervention_demand = NEW.bo_intervention_demand , io_calculation = NEW.bo_io_calculation , kind_water_body = NEW.bo_kind_water_body , outlet_pipe_clear_height = NEW.bo_outlet_pipe_clear_height , q347 = NEW.bo_q347 , relevance_matrix = NEW.bo_relevance_matrix , relevant_slope = NEW.bo_relevant_slope , surface_water_bodies = NEW.bo_surface_water_bodies , water_specific_discharge_freight_nh4_n_current = NEW.bo_water_specific_discharge_freight_nh4_n_current , water_specific_discharge_freight_nh4_n_current_opt = NEW.bo_water_specific_discharge_freight_nh4_n_current_opt , water_specific_discharge_freight_nh4_n_planned = NEW.bo_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;