b1nary0mega
9/1/2015 - 5:51 PM

Delete all HH units

Delete all HH units

/*
FILE: Delete_Unit.sql
AUTH: James R. Aylesworth
DATE: Sep 16, 2011
*****************************************************
Use with CAUTION:
This file will completely obliterate a unit AND its
Employees from MSS!
*****************************************************
*/
DELETE FROM EMPLOYEE_PREFS WHERE UNIT_ID IN (SELECT DISTINCT UNIT_ID FROM UNIT_SPEC WHERE FACILITY_ID = 'HH');
DELETE FROM EMPLOYEE_PROFILE WHERE UNIT_ID IN (SELECT DISTINCT UNIT_ID FROM UNIT_SPEC WHERE FACILITY_ID = 'HH');
DELETE FROM EMPLOYEE_TIMES WHERE unit_id in (Select distinct unit_id from UNIT_SPEC where FACILITY_ID = 'HH');
DELETE FROM FINALIZED WHERE UNIT_ID IN (SELECT DISTINCT UNIT_ID FROM UNIT_SPEC WHERE FACILITY_ID = 'HH');
DELETE FROM FLT_EMPL WHERE ORG_UNIT in (Select distinct unit_id from UNIT_SPEC where FACILITY_ID = 'HH');
DELETE FROM GROUPS WHERE UNIT_ID in (Select distinct unit_id from UNIT_SPEC where FACILITY_ID = 'HH');
DELETE FROM IER_CERTIFICATIONS WHERE UNIT_ID IN (SELECT DISTINCT UNIT_ID FROM UNIT_SPEC WHERE FACILITY_ID = 'HH');
DELETE FROM IER_COMMUNITY WHERE UNIT_ID IN (SELECT DISTINCT UNIT_ID FROM UNIT_SPEC WHERE FACILITY_ID = 'HH');
DELETE FROM IER_COURSES WHERE UNIT_ID IN (SELECT DISTINCT UNIT_ID FROM UNIT_SPEC WHERE FACILITY_ID = 'HH');
DELETE FROM IER_DEGREE WHERE unit_id in (Select distinct unit_id from UNIT_SPEC where FACILITY_ID = 'HH');
DELETE FROM IER_HONORS WHERE unit_id in (Select distinct unit_id from UNIT_SPEC where FACILITY_ID = 'HH');
DELETE FROM IER_INSERVICE WHERE UNIT_ID IN (SELECT DISTINCT UNIT_ID FROM UNIT_SPEC WHERE FACILITY_ID = 'HH');
DELETE FROM IER_LIFE_CERTS WHERE UNIT_ID IN (SELECT DISTINCT UNIT_ID FROM UNIT_SPEC WHERE FACILITY_ID = 'HH');
DELETE FROM IER_ORGANIZATIONS WHERE UNIT_ID IN (SELECT DISTINCT UNIT_ID FROM UNIT_SPEC WHERE FACILITY_ID = 'HH');
DELETE FROM IER_PRESENTATIONS WHERE UNIT_ID IN (SELECT DISTINCT UNIT_ID FROM UNIT_SPEC WHERE FACILITY_ID = 'HH');
DELETE FROM IER_PUBLICATIONS WHERE UNIT_ID IN (SELECT DISTINCT UNIT_ID FROM UNIT_SPEC WHERE FACILITY_ID = 'HH');
DELETE FROM IER_TEAMS WHERE unit_id in (Select distinct unit_id from UNIT_SPEC where FACILITY_ID = 'HH');
DELETE FROM OT_REQ WHERE unit_id in (Select distinct unit_id from UNIT_SPEC where FACILITY_ID = 'HH');
DELETE FROM SLOTS WHERE unit_id in (Select distinct unit_id from UNIT_SPEC where FACILITY_ID = 'HH');
DELETE FROM SLOT_LIMITS WHERE UNIT_ID in (Select distinct unit_id from UNIT_SPEC where FACILITY_ID = 'HH');
DELETE FROM STFF_SHT_CMMT WHERE UNIT_ID in (Select distinct unit_id from UNIT_SPEC where FACILITY_ID = 'HH');
DELETE FROM SUB_GROUP WHERE unit_id in (Select distinct unit_id from UNIT_SPEC where FACILITY_ID = 'HH');
DELETE FROM TIME_BLOCK_SPEC WHERE unit_id in (Select distinct unit_id from UNIT_SPEC where FACILITY_ID = 'HH');
DELETE FROM UNIT_EVENTS WHERE UNIT_ID IN (SELECT DISTINCT UNIT_ID FROM UNIT_SPEC WHERE FACILITY_ID = 'HH');
DELETE FROM UNIT_NP_TIME WHERE UNIT_ID IN (SELECT DISTINCT UNIT_ID FROM UNIT_SPEC WHERE FACILITY_ID = 'HH');
DELETE FROM UNIT_SPEC WHERE unit_id in (Select distinct unit_id from UNIT_SPEC where FACILITY_ID = 'HH');
DELETE FROM UNIT_TIMES WHERE unit_id in (Select distinct unit_id from UNIT_SPEC where FACILITY_ID = 'HH');
DELETE FROM USER_ACCESS_LOG WHERE UNIT_ID in (Select distinct unit_id from UNIT_SPEC where FACILITY_ID = 'HH');
DELETE FROM USER_FEEDBACK WHERE UNIT_ID in (Select distinct unit_id from UNIT_SPEC where FACILITY_ID = 'HH');