SELECT BO1.BO_ID , RC.REL_CLASS_ID , REL.BO_REL_ID , BO2.BO_ID , RELT.REL_TYPE_ID FROM PS_BO BO1 , PS_BO BO2 , PS_RBW_REL_CLASS RC , PS_RBW_REL_CLS_ROL RCR , PS_BO_REL_TYPE RELT , PS_BO_REL REL WHERE (BO1.BO_ID = REL.BO_ID_1 OR BO1.BO_ID = REL.BO_ID_2) AND (REL.ROLE_TYPE_ID_1 = RELT.ROLE_TYPE_ID_1 OR REL.ROLE_TYPE_ID_2 = RELT.ROLE_TYPE_ID_1) AND (BO2.BO_ID = REL.BO_ID_1 OR BO2.BO_ID = REL.BO_ID_2) AND BO1.BO_ID <> BO2.BO_ID AND RELT.REL_TYPE_ID = REL.REL_TYPE_ID AND RC.REL_CLASS_ID = RCR.REL_CLASS_ID AND RCR.REL_TYPE_ID = RELT.REL_TYPE_ID AND RC.ACTIVE_FLG = 'Y' AND REL.START_DT <= %CurrentDateIn AND (REL.END_DT > %CurrentDateIn OR REL.END_DT IS NULL) AND RC.NEW_BO_FLG <> 'Y'
|