tww
.tww_app
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
ft_vw_tww_overflow_update()
Parameters
Name
Type
Mode
IN
Definition
DECLARE BEGIN UPDATE tww_od.overflow SET actuation = NEW.actuation , adjustability = NEW.adjustability , brand = NEW.brand , control = NEW.control , discharge_point = NEW.discharge_point , fk_control_center = NEW.fk_control_center , fk_dataowner = NEW.fk_dataowner , fk_overflow_char = NEW.fk_overflow_char , fk_overflow_to = NEW.fk_overflow_to , fk_provider = NEW.fk_provider , fk_wastewater_node = NEW.fk_wastewater_node , function = NEW.function , gross_costs = NEW.gross_costs , identifier = NEW.identifier , last_modification = NEW.last_modification , qon_dim = NEW.qon_dim , remark = NEW.remark , signal_transmission = NEW.signal_transmission , subsidies = NEW.subsidies WHERE obj_id = OLD.obj_id; IF OLD.overflow_type <> NEW.overflow_type THEN CASE WHEN OLD.overflow_type = 'leapingweir'::tww_app.overflow_type THEN DELETE FROM tww_od.leapingweir WHERE obj_id = OLD.obj_id; WHEN OLD.overflow_type = 'prank_weir'::tww_app.overflow_type THEN DELETE FROM tww_od.prank_weir WHERE obj_id = OLD.obj_id; WHEN OLD.overflow_type = 'pump'::tww_app.overflow_type THEN DELETE FROM tww_od.pump WHERE obj_id = OLD.obj_id; END CASE; CASE WHEN NEW.overflow_type = 'leapingweir'::tww_app.overflow_type THEN INSERT INTO tww_od.leapingweir (obj_id) VALUES (OLD.obj_id); WHEN NEW.overflow_type = 'prank_weir'::tww_app.overflow_type THEN INSERT INTO tww_od.prank_weir (obj_id) VALUES (OLD.obj_id); WHEN NEW.overflow_type = 'pump'::tww_app.overflow_type THEN INSERT INTO tww_od.pump (obj_id) VALUES (OLD.obj_id); ELSE -- do nothing END CASE; END IF; CASE WHEN NEW.overflow_type = 'leapingweir'::tww_app.overflow_type THEN UPDATE tww_od.leapingweir leapingweir SET obj_id = OLD.obj_id , length = NEW.length , opening_shape = NEW.opening_shape , width = NEW.width WHERE obj_id = OLD.obj_id; WHEN NEW.overflow_type = 'prank_weir'::tww_app.overflow_type THEN UPDATE tww_od.prank_weir prank_weir SET obj_id = OLD.obj_id , hydraulic_overflow_length = NEW.hydraulic_overflow_length , level_max = NEW.level_max , level_min = NEW.level_min , weir_edge = NEW.weir_edge , weir_kind = NEW.weir_kind WHERE obj_id = OLD.obj_id; WHEN NEW.overflow_type = 'pump'::tww_app.overflow_type THEN UPDATE tww_od.pump pump SET obj_id = OLD.obj_id , construction_type = NEW.construction_type , operating_point = NEW.operating_point , placement_of_actuation = NEW.placement_of_actuation , placement_of_pump = NEW.placement_of_pump , pump_flow_max_single = NEW.pump_flow_max_single , pump_flow_min_single = NEW.pump_flow_min_single , start_level = NEW.start_level , stop_level = NEW.stop_level WHERE obj_id = OLD.obj_id; ELSE RAISE NOTICE 'vw_tww_overflow type not known (%)', NEW.overflow_type; -- ERROR END CASE; RETURN NEW; END;