SELECT 0 , S0.LM_CI_ID , %DateNull , 0 , M307A.MESSAGE_TEXT FROM PS_LM_CI_TBL S0 LEFT OUTER JOIN PSMSGCATDEFN M307A ON M307A.MESSAGE_SET_NBR = 18088 AND M307A.MESSAGE_NBR = 307 WHERE %CurrentDateIn BETWEEN S0.EFFDT AND S0.LM_END_EFFDT AND NOT EXISTS ( SELECT 1 FROM PS_LM_ACT X0 WHERE X0.LM_CI_ID = S0.LM_CI_ID) UNION SELECT S1.LM_ACT_ID , S1.LM_CI_ID , %DateNull , 0 , M307B.MESSAGE_TEXT FROM PS_LM_ACT S1 LEFT OUTER JOIN PSMSGCATDEFN M307B ON M307B.MESSAGE_SET_NBR = 18088 AND M307B.MESSAGE_NBR = 307 WHERE S1.LM_DISP_DATES <> 'Y' OR NOT EXISTS ( SELECT 1 FROM PS_LM_SES X1 WHERE X1.LM_ACT_ID = S1.LM_ACT_ID) UNION SELECT A2.LM_ACT_ID , A2.LM_CI_ID , S2.LM_SES_DT , 0 , M307C.MESSAGE_TEXT FROM PS_LM_SES S2 , PS_LM_ACT A2 LEFT OUTER JOIN PSMSGCATDEFN M307C ON M307C.MESSAGE_SET_NBR = 18088 AND M307C.MESSAGE_NBR = 307 WHERE A2.LM_ACT_ID = S2.LM_ACT_ID AND A2.LM_DISP_DATES = 'Y' AND S2.LM_SES_DT = ( SELECT MAX(X2.LM_SES_DT) FROM PS_LM_SES X2 WHERE X2.LM_ACT_ID = S2.LM_ACT_ID AND X2.LM_LC_ID = S2.LM_LC_ID AND X2.LM_SES_DT < %CurrentDateIn) UNION %Sql(LM_SRCH_EVENT_SQL,7,308,<=,M308) UNION %Sql(LM_SRCH_EVENT_SQL,30,309,<=,M309) UNION %Sql(LM_SRCH_EVENT_SQL,60,310,<=,M310) UNION %Sql(LM_SRCH_EVENT_SQL,90,311,<=,M311) UNION %Sql(LM_SRCH_EVENT_SQL,90,312,>=,M312)
|