tww
.tww_app
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
update_depth(_obj_id text, _all boolean DEFAULT false)
Parameters
Name
Type
Mode
_obj_id
text
IN
_all
boolean
IN
Definition
DECLARE myrec record; BEGIN UPDATE tww_od.wastewater_structure ws SET _depth = depth FROM ( SELECT WS.obj_id, CO.level - COALESCE(MIN(NO.bottom_level), MIN(RP.level)) as depth FROM tww_od.wastewater_structure WS LEFT JOIN tww_od.cover CO on WS.fk_main_cover = CO.obj_id LEFT JOIN tww_od.wastewater_networkelement NE ON NE.fk_wastewater_structure = WS.obj_id RIGHT JOIN tww_od.wastewater_node NO on NO.obj_id = NE.obj_id LEFT JOIN tww_od.reach_point RP ON RP.fk_wastewater_networkelement = NE.obj_id WHERE _all OR WS.obj_id = _obj_id GROUP BY WS.obj_id, CO.level ) ws_depths where ws.obj_id = ws_depths.obj_id; END