DROP TABLE IF EXISTS SEC_USR_CLS_CDTBL  CASCADE;
DROP TABLE IF EXISTS SEC_USR_TBL  CASCADE;
DROP TABLE IF EXISTS SEC_USR_CLM_TBL  CASCADE;
DROP TABLE IF EXISTS SEC_USR_EXTRN_LGN_TBL  CASCADE;
DROP TABLE IF EXISTS SEC_ROL_TBL  CASCADE;
DROP TABLE IF EXISTS SEC_USR_ROL_ASSOC_TBL  CASCADE;
DROP TABLE IF EXISTS SEC_POL_TBL  CASCADE;
DROP TABLE IF EXISTS SEC_ROL_POL_ASSOC_TBL  CASCADE;
DROP TABLE IF EXISTS SEC_DEV_TBL  CASCADE;
DROP TABLE IF EXISTS SEC_APP_TBL  CASCADE;
DROP TABLE IF EXISTS SEC_DEV_POL_ASSOC_TBL  CASCADE;
DROP TABLE IF EXISTS SEC_APP_POL_ASSOC_TBL  CASCADE;
DROP TABLE IF EXISTS PHON_ALG_TBL  CASCADE;
DROP TABLE IF EXISTS PHON_VAL_TBL  CASCADE;
DROP TABLE IF EXISTS CD_TBL  CASCADE;
DROP TABLE IF EXISTS CD_CLS_TBL  CASCADE;
DROP TABLE IF EXISTS CD_SET_TBL  CASCADE;
DROP TABLE IF EXISTS CD_SET_MEM_ASSOC_TBL  CASCADE;
DROP SEQUENCE IF EXISTS CD_VRSN_SEQ CASCADE;
DROP TABLE IF EXISTS CD_VRSN_TBL  CASCADE;
DROP TABLE IF EXISTS CD_NAME_TBL  CASCADE;
DROP TABLE IF EXISTS CD_SYS_TBL  CASCADE;
DROP TABLE IF EXISTS CD_REL_TYP_CDTBL  CASCADE;
DROP TABLE IF EXISTS REF_TERM_TBL  CASCADE;
DROP TABLE IF EXISTS CD_REF_TERM_ASSOC_TBL  CASCADE;
DROP TABLE IF EXISTS REF_TERM_NAME_TBL  CASCADE;
DROP TABLE IF EXISTS CD_REL_ASSOC_TBL  CASCADE;
DROP FUNCTION IF EXISTS ASSRT_CD_CLS( UUID, VARCHAR(32));
DROP FUNCTION IF EXISTS IS_CD_SET_MEM(UUID,VARCHAR(32));
DROP TABLE IF EXISTS EXT_TYP_TBL  CASCADE;
DROP TABLE IF EXISTS ASGN_AUT_TBL  CASCADE;
DROP TABLE IF EXISTS ASGN_AUT_SCP_TBL  CASCADE;
DROP TABLE IF EXISTS ID_TYP_TBL  CASCADE;
DROP TABLE IF EXISTS TPL_DEF_TBL  CASCADE;
DROP TABLE IF EXISTS ACT_TBL  CASCADE;
DROP TABLE IF EXISTS ACT_VRSN_TBL  CASCADE;
DROP TABLE IF EXISTS ACT_ID_TBL  CASCADE;
DROP TABLE IF EXISTS ACT_REL_TBL  CASCADE;
DROP TABLE IF EXISTS ACT_EXT_TBL  CASCADE;
DROP TABLE IF EXISTS CNTRL_ACT_TBL  CASCADE;
DROP TABLE IF EXISTS OBS_TBL  CASCADE;
DROP TABLE IF EXISTS QTY_OBS_TBL  CASCADE;
DROP TABLE IF EXISTS CD_OBS_TBL  CASCADE;
DROP TABLE IF EXISTS TXT_OBS_TBL  CASCADE;
DROP TABLE IF EXISTS PAT_ENC_TBL  CASCADE;
DROP TABLE IF EXISTS SUB_ADM_TBL  CASCADE;
DROP TABLE IF EXISTS ACT_TAG_TBL  CASCADE;
DROP TABLE IF EXISTS ACT_POL_ASSOC_TBL  CASCADE;
DROP TABLE IF EXISTS ENT_TBL  CASCADE;
DROP FUNCTION IF EXISTS IS_ENT_CLS(UUID,VARCHAR(32));
DROP TABLE IF EXISTS ENT_TAG_TBL  CASCADE;
DROP SEQUENCE IF EXISTS ENT_VRSN_SEQ;
DROP TABLE IF EXISTS ENT_VRSN_TBL  CASCADE;
DROP TABLE IF EXISTS ENT_REL_TBL  CASCADE;
DROP TABLE IF EXISTS ENT_ADDR_TBL  CASCADE;
DROP TABLE IF EXISTS ENT_ADDR_CMP_VAL_TBL  CASCADE;
DROP TABLE IF EXISTS ENT_ADDR_CMP_TBL  CASCADE;
DROP TABLE IF EXISTS ENT_NAME_TBL  CASCADE;
DROP TABLE IF EXISTS ENT_NAME_CMP_TBL  CASCADE;
DROP TABLE IF EXISTS ENT_EXT_TBL  CASCADE;
DROP FUNCTION IF EXISTS IS_ENT_ID_UNQ (UUID,VARCHAR(64));
DROP TABLE IF EXISTS ENT_ID_TBL  CASCADE;
DROP TABLE IF EXISTS ENT_TEL_TBL  CASCADE;
DROP TABLE IF EXISTS PLC_TBL  CASCADE;
DROP TABLE IF EXISTS PLC_SVC_TBL  CASCADE;
DROP TABLE IF EXISTS ORG_TBL  CASCADE;
DROP TABLE IF EXISTS APP_ENT_TBL  CASCADE;
DROP TABLE IF EXISTS DEV_ENT_TBL  CASCADE;
DROP TABLE IF EXISTS MAT_TBL  CASCADE;
DROP TABLE IF EXISTS MMAT_TBL  CASCADE;
DROP TABLE IF EXISTS PSN_TBL  CASCADE;
DROP TABLE IF EXISTS PSN_LNG_TBL  CASCADE;
DROP TABLE IF EXISTS PAT_TBL  CASCADE;
DROP TABLE IF EXISTS PVDR_TBL  CASCADE;
DROP TABLE IF EXISTS USR_ENT_TBL  CASCADE;
DROP TABLE IF EXISTS PROTO_HDLR_TBL  CASCADE;
DROP TABLE IF EXISTS PROTO_TBL  CASCADE;
DROP TABLE IF EXISTS ACT_PROTO_ASSOC_TBL  CASCADE;
DROP TABLE IF EXISTS ACT_NOTE_TBL  CASCADE;
DROP TABLE IF EXISTS ENT_NOTE_TBL  CASCADE;
DROP TABLE IF EXISTS ACT_PTCPT_TBL  CASCADE;
DROP TABLE IF EXISTS ALRT_TBL  CASCADE;
DROP TABLE IF EXISTS ALRT_RCPT_TO_TBL  CASCADE;
DROP SEQUENCE IF EXISTS ACT_VRSN_SEQ;
DROP SEQUENCE IF EXISTS ENT_VRSN_SEQ;
DROP SEQUENCE IF EXISTS ENT_VRSN_SEQ;
DROP SEQUENCE IF EXISTS NAME_VAL_SEQ;
DROP SEQUENCE IF EXISTS PHON_VAL_SEQ;
DROP SEQUENCE IF EXISTS ENT_ADDR_CMP_VAL_SEQ;


-- RETURNS WHETHER THE USER ACCOUNT IS LOCKED
DROP FUNCTION IF EXISTS IS_USR_LOCK(TEXT);
DROP FUNCTION IF EXISTS AUTH_USR (TEXT,TEXT,INT);
DROP FUNCTION IF EXISTS AUTH_APP (TEXT,TEXT);
DROP FUNCTION IF EXISTS AUTH_DEV (TEXT,TEXT);
DROP FUNCTION IF EXISTS GET_SCH_VRSN();
