SELECT LM_ACT_ID , LM_CI_ID FROM PS_LM_ACT WHERE LM_ACT_STATUS = '1' AND EXISTS ( SELECT 1 FROM PS_LM_ACT_SEC S WHERE S.LM_ACT_ID = PS_LM_ACT.LM_ACT_ID) AND ( (LM_LST_ENRL_START = 'Y' AND ((LM_START_DT IS NOT NULL AND %CurrentDateIn <= LM_START_DT) OR (LM_START_DT IS NULL AND ((LM_END_DT IS NOT NULL AND %CurrentDateIn <= LM_END_DT) OR LM_END_DT IS NULL)))) OR (LM_LST_ENRL_START <> 'Y' AND ((LM_LST_ENRL_DT IS NOT NULL AND %CurrentDateIn <= LM_LST_ENRL_DT) OR (LM_LST_ENRL_DT IS NULL AND ((LM_LST_ENRL_DAYS > 0 AND (LM_LST_ENRL_TYPE = '1' AND ((LM_START_DT IS NOT NULL AND %CurrentDateIn <= %DateAdd(LM_START_DT,LM_LST_ENRL_DAYS * -1)) OR (LM_START_DT IS NULL AND ((LM_END_DT IS NOT NULL AND %CurrentDateIn <= LM_END_DT) OR LM_END_DT IS NULL))) ) OR (LM_LST_ENRL_TYPE <> '1' AND ((LM_START_DT IS NOT NULL AND %CurrentDateIn <= %DateAdd(LM_START_DT,LM_LST_ENRL_DAYS)) OR (LM_START_DT IS NULL AND ((LM_END_DT IS NOT NULL AND %CurrentDateIn <= LM_END_DT) OR LM_END_DT IS NULL))) ) ) OR (LM_LST_ENRL_DAYS = 0 AND (((LM_END_DT IS NOT NULL AND %CurrentDateIn <= LM_END_DT) OR LM_END_DT IS NULL))) ) ) ) ))
|