tww
.tww_app
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
ft_vw_tww_maintenance_event_insert()
Parameters
Name
Type
Mode
IN
Definition
DECLARE BEGIN INSERT INTO tww_od.maintenance_event ( obj_id , base_data , cost , data_details , duration , fk_dataowner , fk_measure , fk_operating_company , fk_provider , identifier , last_modification , operator , reason , remark , result , status , time_point ) VALUES ( COALESCE( NEW.obj_id, tww_app.generate_oid('tww_od'::text, 'maintenance_event'::text) ) , NEW.base_data , NEW.cost , NEW.data_details , NEW.duration , NEW.fk_dataowner , NEW.fk_measure , NEW.fk_operating_company , NEW.fk_provider , NEW.identifier , NEW.last_modification , NEW.operator , NEW.reason , NEW.remark , NEW.result , NEW.status , NEW.time_point ) RETURNING obj_id INTO NEW.obj_id; CASE WHEN NEW.maintenance_event_type = 'bio_ecol_assessment'::tww_app.maintenance_event_type THEN INSERT INTO tww_od.bio_ecol_assessment ( obj_id , comparison_last , date_last_examen , impact_auxiliary_indic , impact_external_aspect , impact_macroinvertebrates , impact_water_plants , intervention_demand , io_calculation , kind_water_body , outlet_pipe_clear_height , q347 , relevance_matrix , relevant_slope , surface_water_bodies , water_specific_discharge_freight_nh4_n_current , water_specific_discharge_freight_nh4_n_current_opt , water_specific_discharge_freight_nh4_n_planned ) VALUES ( NEW.obj_id -- obj_id , NEW.bo_comparison_last , NEW.bo_date_last_examen , NEW.bo_impact_auxiliary_indic , NEW.bo_impact_external_aspect , NEW.bo_impact_macroinvertebrates , NEW.bo_impact_water_plants , NEW.bo_intervention_demand , NEW.bo_io_calculation , NEW.bo_kind_water_body , NEW.bo_outlet_pipe_clear_height , NEW.bo_q347 , NEW.bo_relevance_matrix , NEW.bo_relevant_slope , NEW.bo_surface_water_bodies , NEW.bo_water_specific_discharge_freight_nh4_n_current , NEW.bo_water_specific_discharge_freight_nh4_n_current_opt , NEW.bo_water_specific_discharge_freight_nh4_n_planned ); WHEN NEW.maintenance_event_type = 'examination'::tww_app.maintenance_event_type THEN INSERT INTO tww_od.examination ( obj_id , equipment , fk_reach_point , from_point_identifier , inspected_length , recording_type , to_point_identifier , vehicle , videonumber , weather ) VALUES ( NEW.obj_id -- obj_id , NEW.ex_equipment , NEW.ex_fk_reach_point , NEW.ex_from_point_identifier , NEW.ex_inspected_length , NEW.ex_recording_type , NEW.ex_to_point_identifier , NEW.ex_vehicle , NEW.ex_videonumber , NEW.ex_weather ); WHEN NEW.maintenance_event_type = 'maintenance'::tww_app.maintenance_event_type THEN INSERT INTO tww_od.maintenance ( obj_id , kind ) VALUES ( NEW.obj_id -- obj_id , NEW.mn_kind ); ELSE RAISE NOTICE 'vw_tww_maintenance_event type not known (%)', NEW.maintenance_event_type; -- ERROR END CASE; RETURN NEW; END;