 
 DECLARE
 	cursor c_data is
-	SELECT PROP_ID,RULE_ID FROM KRMS_PROP_T@KC_STAG_DB_LINK
-	WHERE RULE_ID in ( SELECT RULE_ID FROM KRMS_RULE_T WHERE typ_id IN ( SELECT typ_id FROM krms_typ_t WHERE nm = 'Route to PeopleFlow') );
+	SELECT PROP_ID,RULE_ID FROM KRMS_PROP_T@KC_STAG_DB_LINK	
+	WHERE RULE_ID IN ( SELECT RULE_ID FROM KRMS_ACTN_T WHERE typ_id IN ( SELECT typ_id FROM krms_typ_t WHERE nm = 'Route to PeopleFlow') );
 	r_data c_data%rowtype;
 	ls_seq KRMS_PROP_T.PROP_ID%type;
 


END;
/
DELETE FROM KRMS_AGENDA_ATTR_T WHERE AGENDA_ID IN (SELECT AGENDA_ID FROM KRMS_AGENDA_ITM_T WHERE RULE_ID IN ( SELECT RULE_ID FROM KRMS_RULE_T WHERE typ_id IN ( SELECT typ_id FROM krms_typ_t WHERE nm = 'Route to PeopleFlow') ))
/
DELETE FROM KRMS_AGENDA_T WHERE AGENDA_ID IN (SELECT AGENDA_ID FROM KRMS_AGENDA_ITM_T WHERE RULE_ID IN ( SELECT RULE_ID FROM KRMS_RULE_T WHERE typ_id IN ( SELECT typ_id FROM krms_typ_t WHERE nm = 'Route to PeopleFlow') ))
/
DELETE FROM KRMS_AGENDA_ITM_T WHERE RULE_ID IN ( SELECT RULE_ID FROM KRMS_RULE_T WHERE typ_id IN ( SELECT typ_id FROM krms_typ_t WHERE nm = 'Route to PeopleFlow') )
/
DECLARE
	cursor c_data is
	select t2.agenda_id, t1.rule_id from KRMS_AGENDA_ITM_T t1 inner join KRMS_AGENDA_T t2 on t1.AGENDA_ID = t2.AGENDA_ID
	where t1.RULE_ID in ( SELECT RULE_ID FROM KRMS_RULE_T WHERE typ_id IN ( SELECT typ_id FROM krms_typ_t WHERE nm = 'Route to PeopleFlow') );	
	r_data c_data%rowtype;	
	ls_seq KRMS_AGENDA_T.AGENDA_ID%type;


ALTER TABLE KRMS_RULE_T DISABLE CONSTRAINT KRMS_RULE_FK1
/
---------------------------
DELETE FROM KRMS_CMPND_PROP_PROPS_T WHERE PROP_ID in (  SELECT PROP_ID FROM KRMS_PROP_T WHERE RULE_ID in ( SELECT RULE_ID FROM KRMS_ACTN_T WHERE typ_id IN ( SELECT typ_id FROM krms_typ_t WHERE nm = 'Route to PeopleFlow') ) )
/
DELETE FROM KRMS_PROP_PARM_T WHERE PROP_ID in ( SELECT PROP_ID FROM KRMS_PROP_T WHERE RULE_ID in ( SELECT RULE_ID FROM KRMS_ACTN_T WHERE typ_id IN ( SELECT typ_id FROM krms_typ_t WHERE nm = 'Route to PeopleFlow') ) )
/
DELETE FROM KRMS_PROP_T WHERE RULE_ID in ( SELECT RULE_ID FROM KRMS_ACTN_T WHERE typ_id IN ( SELECT typ_id FROM krms_typ_t WHERE nm = 'Route to PeopleFlow') )
/
DELETE FROM KRMS_RULE_ATTR_T WHERE RULE_ID in ( SELECT RULE_ID FROM KRMS_ACTN_T WHERE typ_id IN ( SELECT typ_id FROM krms_typ_t WHERE nm = 'Route to PeopleFlow') )
/
DELETE FROM KRMS_RULE_T WHERE RULE_ID IN ( SELECT RULE_ID FROM KRMS_ACTN_T WHERE typ_id IN ( SELECT typ_id FROM krms_typ_t WHERE nm = 'Route to PeopleFlow') )
/
drop table TEMP_MAPPING_KRMS_RULE_T
/
