2027: WHERE UC.unit_config_header_id = c_uc_header_id
2028: AND SB.mc_header_id = UC.master_config_id
2029: -- take only the rules which have MRs accomplished on the unit
2030: AND EXISTS (SELECT 'X'
2031: FROM ahl_unit_effectivities_b UE
2032: WHERE UE.mr_header_id = SB.mr_header_id
2033: AND UE.csi_item_instance_id = UC.csi_item_instance_id -- SB MRs are effective on root node
2034: AND UE.accomplished_date IS NOT NULL)
2035: -- take only the MAX sequence rules for a position, among the accomplished MRs
2036: AND SB.rule_sequence = (SELECT MAX(SB2.rule_sequence)
2037: FROM ahl_sb_position_rules SB2
2038: WHERE SB2.relationship_id = SB.relationship_id
2039: AND EXISTS (SELECT 'X'
2040: FROM ahl_unit_effectivities_b UE
2041: WHERE UE.mr_header_id = SB2.mr_header_id
2042: AND UE.csi_item_instance_id = UC.csi_item_instance_id
2043: AND UE.accomplished_date IS NOT NULL))
2044: AND SB.relationship_id = c_relationship_id
2560: WHERE UC.unit_config_header_id = c_uc_header_id
2561: AND SB.mc_header_id = UC.master_config_id
2562: -- take only the rules which have MRs accomplished on the unit
2563: AND EXISTS (SELECT 'X'
2564: FROM ahl_unit_effectivities_b UE
2565: WHERE UE.mr_header_id = SB.mr_header_id
2566: AND UE.csi_item_instance_id = UC.csi_item_instance_id -- SB MRs are effective on root node
2567: AND UE.accomplished_date IS NOT NULL)
2568: -- take only the MAX sequence rules for a position, among the accomplished MRs
2569: AND SB.rule_sequence = (SELECT MAX(SB2.rule_sequence)
2570: FROM ahl_sb_position_rules SB2
2571: WHERE SB2.relationship_id = SB.relationship_id
2572: AND EXISTS (SELECT 'X'
2573: FROM ahl_unit_effectivities_b UE
2574: WHERE UE.mr_header_id = SB2.mr_header_id
2575: AND UE.csi_item_instance_id = UC.csi_item_instance_id
2576: AND UE.accomplished_date IS NOT NULL))
2577: AND SB.relationship_id = c_relationship_id