tww
.tww_app
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
ft_vw_tww_damage_insert()
Parameters
Name
Type
Mode
IN
Definition
DECLARE BEGIN INSERT INTO tww_od.damage ( obj_id , comments , connection , fk_dataowner , fk_examination , fk_provider , last_modification , line_damage , single_damage_class , video_counter , view_parameters ) VALUES ( COALESCE( NEW.obj_id, tww_app.generate_oid('tww_od'::text, 'damage'::text) ) , NEW.comments , NEW.connection , NEW.fk_dataowner , NEW.fk_examination , NEW.fk_provider , NEW.last_modification , NEW.line_damage , NEW.single_damage_class , NEW.video_counter , NEW.view_parameters ) RETURNING obj_id INTO NEW.obj_id; CASE WHEN NEW.damage_type = 'channel'::tww_app.damage_type THEN INSERT INTO tww_od.damage_channel ( obj_id , channel_damage_begin , channel_damage_code , channel_damage_end , channel_distance , channel_quantification1 , channel_quantification2 ) VALUES ( NEW.obj_id -- obj_id , NEW.channel_damage_begin , NEW.channel_damage_code , NEW.channel_damage_end , NEW.channel_distance , NEW.channel_quantification1 , NEW.channel_quantification2 ); WHEN NEW.damage_type = 'manhole'::tww_app.damage_type THEN INSERT INTO tww_od.damage_manhole ( obj_id , manhole_damage_begin , manhole_damage_code , manhole_damage_end , manhole_distance , manhole_quantification1 , manhole_quantification2 , manhole_shaft_area ) VALUES ( NEW.obj_id -- obj_id , NEW.manhole_damage_begin , NEW.manhole_damage_code , NEW.manhole_damage_end , NEW.manhole_distance , NEW.manhole_quantification1 , NEW.manhole_quantification2 , NEW.manhole_shaft_area ); ELSE NULL; END CASE; RETURN NEW; END;