Advertisement
3nids

Untitled

Sep 17th, 2015
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE OR REPLACE RULE rl_vw_installation_merge_update AS ON UPDATE TO qwat_od.vw_installation_merge DO INSTEAD
  2.             (
  3.             UPDATE qwat_od.installation SET name = NEW.name, identification = NEW.identification, fk_parent = NEW.fk_parent, fk_status = NEW.fk_status, fk_distributor = NEW.fk_distributor, fk_remote = NEW.fk_remote, fk_watertype = NEW.fk_watertype, fk_locationtype = NEW.fk_locationtype, fk_precisionalti = NEW.fk_precisionalti, year = NEW.year, year_end = NEW.year_end, parcel = NEW.parcel, eca = NEW.eca, altitude = NEW.altitude, remark = NEW.remark, open_water_surface = NEW.open_water_surface, fk_node = NEW.fk_node, fk_district = NEW.fk_district, fk_pressurezone = NEW.fk_pressurezone, fk_printmap = NEW.fk_printmap, _district = NEW._district, _printmaps = NEW._printmaps, geometry = NEW.geometry, geometry_alt1 = NEW.geometry_alt1, geometry_alt2 = NEW.geometry_alt2, _geometry_alt1_used = NEW._geometry_alt1_used, _geometry_alt2_used = NEW._geometry_alt2_used, geometry_polygon = NEW.geometry_polygon, label_1_visible = NEW.label_1_visible, label_1_x = NEW.label_1_x, label_1_y = NEW.label_1_y, label_1_rotation = NEW.label_1_rotation, label_1_text = NEW.label_1_text, label_2_visible = NEW.label_2_visible, label_2_x = NEW.label_2_x, label_2_y = NEW.label_2_y, label_2_rotation = NEW.label_2_rotation, label_2_text = NEW.label_2_text WHERE id = OLD.id;
  4.             /* Allow change type */
  5.             IF OLD.installation_type <> NEW.installation_type THEN CASE
  6.            
  7.                 WHEN OLD.installation_type = 'chamber' THEN DELETE FROM qwat_od.installation_chamber WHERE id = OLD.id;
  8.                 WHEN OLD.installation_type = 'pressurecontrol' THEN DELETE FROM qwat_od.installation_pressurecontrol WHERE id = OLD.id;
  9.                 WHEN OLD.installation_type = 'pump' THEN DELETE FROM qwat_od.installation_pump WHERE id = OLD.id;
  10.                 WHEN OLD.installation_type = 'source' THEN DELETE FROM qwat_od.installation_source WHERE id = OLD.id;
  11.                 WHEN OLD.installation_type = 'tank' THEN DELETE FROM qwat_od.installation_tank WHERE id = OLD.id;
  12.                 WHEN OLD.installation_type = 'treatment' THEN DELETE FROM qwat_od.installation_treatment WHERE id = OLD.id;
  13.             END CASE;
  14.             CASE
  15.                 WHEN NEW.installation_type = 'chamber' THEN INSERT INTO qwat_od.installation_chamber (id) VALUES (OLD.id);
  16.                 WHEN NEW.installation_type = 'pressurecontrol' THEN INSERT INTO qwat_od.installation_pressurecontrol (id) VALUES (OLD.id);
  17.                 WHEN NEW.installation_type = 'pump' THEN INSERT INTO qwat_od.installation_pump (id) VALUES (OLD.id);
  18.                 WHEN NEW.installation_type = 'source' THEN INSERT INTO qwat_od.installation_source (id) VALUES (OLD.id);
  19.                 WHEN NEW.installation_type = 'tank' THEN INSERT INTO qwat_od.installation_tank (id) VALUES (OLD.id);
  20.                 WHEN NEW.installation_type = 'treatment' THEN INSERT INTO qwat_od.installation_treatment (id) VALUES (OLD.id);
  21.             END CASE;
  22.             END IF;
  23.             CASE
  24.                 WHEN NEW.installation_type = 'chamber' THEN UPDATE qwat_od.installation_chamber SET fk_object_reference = NEW.fk_object_reference, networkseparation = NEW.networkseparation, meter = NEW.meter, depth = NEW.depth, no_valves = NEW.no_valves WHERE id = OLD.id;
  25.                 WHEN NEW.installation_type = 'pressurecontrol' THEN UPDATE qwat_od.installation_pressurecontrol SET fk_pressurecontrol_type = NEW.fk_pressurecontrol_type WHERE id = OLD.id;
  26.                 WHEN NEW.installation_type = 'pump' THEN UPDATE qwat_od.installation_pump SET fk_pump_type = NEW.fk_pump_type, fk_pipe_in = NEW.fk_pipe_in, fk_pipe_out = NEW.fk_pipe_out, fk_operating = NEW.fk_operating, no_pumps = NEW.no_pumps, rejected_flow = NEW.rejected_flow, manometric_height = NEW.manometric_height WHERE id = OLD.id;
  27.                 WHEN NEW.installation_type = 'source' THEN UPDATE qwat_od.installation_source SET fk_source_type = NEW.fk_source_type, fk_quality = NEW.fk_quality, flow_lowest = NEW.flow_lowest, flow_mean = NEW.flow_mean, flow_concession = NEW.flow_concession, contract_end = NEW.contract_end, gathering_chamber = NEW.gathering_chamber WHERE id = OLD.id;
  28.                 WHEN NEW.installation_type = 'tank' THEN UPDATE qwat_od.installation_tank SET fk_overflow = NEW.fk_overflow, fk_firestorage = NEW.fk_firestorage, storage_total = NEW.storage_total, storage_supply = NEW.storage_supply, storage_fire = NEW.storage_fire, altitude_overflow = NEW.altitude_overflow, altitude_apron = NEW.altitude_apron, height_max = NEW.height_max, fire_valve = NEW.fire_valve, fire_remote = NEW.fire_remote, _litrepercm = NEW._litrepercm, cistern1_fk_type = NEW.cistern1_fk_type, cistern1_dimension_1 = NEW.cistern1_dimension_1, cistern1_dimension_2 = NEW.cistern1_dimension_2, cistern1_storage = NEW.cistern1_storage, _cistern1_litrepercm = NEW._cistern1_litrepercm, cistern2_fk_type = NEW.cistern2_fk_type, cistern2_dimension_1 = NEW.cistern2_dimension_1, cistern2_dimension_2 = NEW.cistern2_dimension_2, cistern2_storage = NEW.cistern2_storage, _cistern2_litrepercm = NEW._cistern2_litrepercm WHERE id = OLD.id;
  29.                 WHEN NEW.installation_type = 'treatment' THEN UPDATE qwat_od.installation_treatment SET sanitization_uv = NEW.sanitization_uv, sanitization_chlorine_liquid = NEW.sanitization_chlorine_liquid, sanitization_chlorine_gazeous = NEW.sanitization_chlorine_gazeous, sanitization_ozone = NEW.sanitization_ozone, filtration_membrane = NEW.filtration_membrane, filtration_sandorgravel = NEW.filtration_sandorgravel, flocculation = NEW.flocculation, activatedcharcoal = NEW.activatedcharcoal, settling = NEW.settling, treatment_capacity = NEW.treatment_capacity WHERE id = OLD.id;END CASE);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement