Advertisement
psi_mmobile

OLD on_set_person_inactive TRIGGER

Sep 14th, 2022
1,250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 1.16 KB | None | 0 0
  1. CREATE OR REPLACE TRIGGER on_set_person_inactive
  2. after UPDATE OF person_status_id ON person
  3. FOR each ROW
  4. DECLARE
  5.     v_timezone operation_center.timezone%TYPE;
  6.     v_date_day DATE;
  7.     v_vehicle_owner_id NUMBER(10); -- only for Sixco for now
  8. BEGIN
  9.     IF :old.person_status_id = 0 AND :NEW.person_status_id IN (1,2) THEN
  10.    
  11.         SELECT oc.timezone, vo.vehicle_owner_id
  12.         INTO v_timezone, v_vehicle_owner_id
  13.         FROM operation_center oc, vo_person_category vpc, vehicle_owner vo
  14.         WHERE vpc.vo_person_category_id = :NEW.vo_person_category_id
  15.         AND vo.vehicle_owner_id = vpc.vehicle_owner_id
  16.         AND oc.operation_center_id = vo.default_operation_center_id;
  17.        
  18.         IF v_vehicle_owner_id = 101408 THEN
  19.        
  20.             v_date_day := TRUNC(touserdate(sysdateutc, v_timezone));
  21.            
  22.             DELETE FROM pd_day
  23.             WHERE person_id = :NEW.person_id
  24.             AND date_day >= v_date_day + 1;
  25.            
  26.             DELETE FROM pd_trf_day
  27.             WHERE person_id = :NEW.person_id
  28.             AND date_day >= v_date_day + 1;
  29.         END IF;
  30.     END IF;
  31.   EXCEPTION WHEN OTHERS THEN
  32.   NULL;
  33. END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement