tww
.tww_app
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
ft_vw_tww_additional_ws_insert()
Parameters
Name
Type
Mode
IN
Definition
BEGIN NEW.identifier = COALESCE(NEW.identifier, NEW.obj_id); INSERT INTO tww_od.wastewater_structure ( obj_id -- , _bottom_label -- , _cover_label , _depth -- , _input_label -- , _label -- , _output_label , accessibility , condition_score , contract_section -- , detail_geometry3d_geometry , elevation_determination , financing , fk_dataowner -- , fk_main_cover -- , fk_main_wastewater_node , fk_operator , fk_owner , fk_provider , gross_costs , identifier , inspection_interval , last_modification , location_name , records , remark , renovation_necessity , replacement_value , rv_base_year , rv_construction_type , status , status_survey_year , structure_condition , subsidies , urgency_figure , year_of_construction , year_of_replacement ) VALUES ( NEW.obj_id -- , NEW._bottom_label -- , NEW._cover_label , NEW._depth -- , NEW._input_label -- , NEW._label -- , NEW._output_label , NEW.accessibility , NEW.condition_score , NEW.contract_section -- , NEW.detail_geometry3d_geometry , NEW.elevation_determination , NEW.financing , NEW.fk_dataowner -- , NEW.fk_main_cover -- , NEW.fk_main_wastewater_node , NEW.fk_operator , NEW.fk_owner , NEW.fk_provider , NEW.gross_costs , NEW.identifier , NEW.inspection_interval , NEW.last_modification , NEW.location_name , NEW.records , NEW.remark , NEW.renovation_necessity , NEW.replacement_value , NEW.rv_base_year , NEW.rv_construction_type , NEW.status , NEW.status_survey_year , NEW.structure_condition , NEW.subsidies , NEW.urgency_figure , NEW.year_of_construction , NEW.year_of_replacement ); CASE WHEN NEW.ws_type = 'wwtp_structure' THEN -- wwtp_structure INSERT INTO tww_od.wwtp_structure ( obj_id , fk_waste_water_treatment_plant , kind ) VALUES ( NEW.obj_id , NEW.wt_fk_waste_water_treatment_plant , NEW.wt_kind ); -- small_treatment_plant WHEN NEW.ws_type = 'small_treatment_plant' THEN INSERT INTO tww_od.small_treatment_plant ( obj_id , approval_number , function , installation_number , remote_monitoring ) VALUES ( NEW.obj_id , NEW.sm_approval_number , NEW.sm_function , NEW.sm_installation_number , NEW.sm_remote_monitoring ); -- drainless_toilet WHEN NEW.ws_type = 'drainless_toilet' THEN INSERT INTO tww_od.drainless_toilet ( obj_id , kind ) VALUES ( NEW.obj_id , NEW.to_kind ); ELSE RAISE NOTICE 'Wastewater structure type not known (%)', NEW.ws_type; -- ERROR END CASE; INSERT INTO tww_app.vw_wastewater_node ( -- _function_hierarchic -- _status -- _usage_current backflow_level_current , bottom_level , elevation_accuracy , fk_dataowner , fk_hydr_geometry , fk_provider , fk_wastewater_structure , function_node_amelioration , identifier , last_modification , obj_id , remark , situation3d_geometry , wwtp_number ) VALUES ( -- NEW.wn__function_hierarchic -- NEW.wn__status -- NEW.wn__usage_current NEW.wn_backflow_level_current , NEW.wn_bottom_level , NEW.wn_elevation_accuracy , COALESCE(NULLIF(NEW.wn_fk_dataowner,''), NEW.fk_dataowner) -- fk_dataowner , NEW.wn_fk_hydr_geometry , COALESCE(NULLIF(NEW.wn_fk_provider,''), NEW.fk_provider) -- fk_provider , NEW.obj_id -- fk_wastewater_structure , NEW.wn_function_node_amelioration , COALESCE(NULLIF(NEW.wn_identifier,''), NEW.identifier) -- identifier , NOW() -- last_modification , NEW.wn_obj_id , NEW.wn_remark , ST_SetSRID(ST_MakePoint(ST_X(NEW.situation3d_geometry), ST_Y(NEW.situation3d_geometry), 'nan'), 2056 ) -- situation3d_geometry , NEW.wn_wwtp_number ); UPDATE tww_od.wastewater_structure SET fk_main_wastewater_node = NEW.wn_obj_id WHERE obj_id = NEW.obj_id; INSERT INTO tww_app.vw_cover ( brand , cover_shape , diameter , fastening , fk_dataowner , fk_provider , fk_wastewater_structure , identifier , last_modification , level , material , obj_id , positional_accuracy , remark , renovation_demand , situation3d_geometry , sludge_bucket , venting ) VALUES ( NEW.co_brand , NEW.co_shape , NEW.co_diameter , NEW.co_fastening , NEW.fk_dataowner -- fk_dataowner , NEW.fk_provider -- fk_provider , NEW.obj_id -- fk_wastewater_structure , COALESCE(NULLIF(NEW.co_identifier,''), NEW.identifier) -- identifier , NOW() -- last_modification , NEW.co_level , NEW.co_material , NEW.co_obj_id , NEW.co_positional_accuracy , NEW.co_remark , NEW.co_renovation_demand , ST_SetSRID(ST_MakePoint(ST_X(NEW.situation3d_geometry), ST_Y(NEW.situation3d_geometry), 'nan'), 2056 ) -- situation3d_geometry , NEW.co_sludge_bucket , NEW.co_venting ); UPDATE tww_od.wastewater_structure SET fk_main_cover = NEW.co_obj_id WHERE obj_id = NEW.obj_id; RETURN NEW; END;