Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE OR REPLACE TRIGGER trg_update_park_capacity before
- INSERT OR DELETE ON parkingslot
- FOR each ROW
- DECLARE
- eletric_cap park.eletric_capacity%TYPE;
- non_eletric_cap park.non_eletric_capacity%TYPE;
- pa park.id_park%TYPE;
- btype bicycletype.id_bicycle_type%TYPE;
- BEGIN
- pa :=:NEW.id_park;
- eletric_cap := 0;
- non_eletric_cap := 0;
- IF inserting THEN
- btype :=:NEW.id_bicycle_type;
- IF btype = 1 THEN
- eletric_cap:= 1;
- ELSE
- non_eletric_cap:= 1;
- END IF;
- ELSE
- btype :=:NEW.id_bicycle_type;
- IF btype = 1 THEN
- eletric_cap:= - 1;
- ELSE
- non_eletric_cap:= - 1;
- END IF;
- END IF;
- UPDATE park
- SET eletric_capacity = eletric_capacity + eletric_cap, non_eletric_capacity = non_eletric_capacity + non_eletric_cap
- WHERE id_park = pa;
- END trg_update_park_capacity;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement