SELECT B.OPRID , A.CAL_RUN_ID , L.LANGUAGE_CD , L.DESCR FROM PS_GP_CAL_RUN A , PS_GP_OPR_RULE_PRF B , PS_GPCN_RW_GEN G , PS_GP_CAL_RUN_LANG L WHERE (B.USED_BY = 'A' OR (B.USED_BY = 'C' AND A.COUNTRY = B.COUNTRY)) AND A.CAL_RUN_ID = L.CAL_RUN_ID AND (EXISTS ( SELECT 'X' FROM PS_GP_CAL_RUN_DTL DTL WHERE A.CAL_RUN_ID = DTL.CAL_RUN_ID AND DTL.CALC_TYPE = 'P') OR EXISTS ( SELECT 'X' FROM PS_GP_CAL_RUN_OFF DT2 WHERE A.CAL_RUN_ID = DT2.CAL_RUN_ID)) AND A.CAL_RUN_ID = G.GPCN_SRC_CAL_RN_ID AND G.PROCESS_INSTANCE = ( SELECT MAX(G2.PROCESS_INSTANCE) FROM PS_GPCN_RW_GEN G2 WHERE G2.GPCN_SRC_CAL_RN_ID = A.CAL_RUN_ID)
|