daily pastebin goal
32%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE OR REPLACE TRIGGER trg_update_park_capacity before
  2. INSERT OR DELETE ON parkingslot
  3.     FOR each ROW
  4. DECLARE
  5.     eletric_cap   park.eletric_capacity%TYPE;
  6.     non_eletric_cap   park.non_eletric_capacity%TYPE;
  7.     pa park.id_park%TYPE;
  8.     btype bicycletype.id_bicycle_type%TYPE;
  9. BEGIN
  10.     IF inserting THEN
  11.         pa :=:NEW.id_park;        
  12.         btype :=:NEW.id_bicycle_type;        
  13.         IF btype = 3 THEN
  14.             SELECT eletric_capacity
  15.             INTO eletric_cap
  16.             FROM park
  17.             WHERE id_park = pa;
  18.             eletric_cap:= eletric_cap + 1;
  19.         ELSE
  20.             SELECT non_eletric_capacity
  21.             INTO non_eletric_cap
  22.             FROM park
  23.             WHERE id_park = pa;
  24.             non_eletric_cap:= non_eletric_cap + 1;
  25.         END IF;
  26.     ELSE
  27.         pa :=:NEW.id_park;      
  28.         btype :=:NEW.id_bicycle_type;
  29.         btype :=:NEW.id_bicycle_type;
  30.         IF btype = 3 THEN
  31.             SELECT eletric_capacity
  32.             INTO eletric_cap
  33.             FROM park
  34.             WHERE id_park = pa;
  35.             eletric_cap:= eletric_cap - 1;
  36.         ELSE
  37.             SELECT non_eletric_capacity
  38.             INTO non_eletric_cap
  39.             FROM park
  40.             WHERE id_park = pa;
  41.             non_eletric_cap:= non_eletric_cap - 1;
  42.         END IF;
  43.     END IF;
  44.     UPDATE park
  45.     SET eletric_capacity = eletric_cap, non_eletric_capacity = non_eletric_cap
  46.     WHERE id_park = pa;
  47. END trg_update_park_capacity;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top