SELECT RSP1.SAD_BPV_INDEX_ID , RSP1.SAD_BPV_MSGUUID , RSP1.SEQNUM , RSPL.LANGUAGE_CD , RSP1.DESCR100 , RSP1.EXT_ORG_ID FROM PS_SAD_BPV_SBB_RSP RSP1 , PS_SAD_BPV_SBR_LNG RSPL WHERE RSP1.SAD_BPV_INDEX_ID = RSPL.SAD_BPV_INDEX_ID AND RSP1.SAD_BPV_MSGUUID = RSPL.SAD_BPV_MSGUUID AND RSP1.SEQNUM = RSPL.SEQNUM UNION SELECT ' ' ,' ' ,999 , D.LANGUAGE_CD , B.DESCR50 , B.EXT_ORG_ID FROM PS_SCC_ORG_EXT_KEY A , PS_EXT_ORG_TBL B ,PS_SAD_BPV_SBB_NLD C ,PS_SAD_BPV_SBB_LNG D WHERE A.EXT_ORG_ID =B.EXT_ORG_ID AND B. EFFDT = ( SELECT MAX(B1.EFFDT) FROM PS_EXT_ORG_TBL B1 WHERE B1.EXT_ORG_ID =B.EXT_ORG_ID AND B1.EFFDT <= %CurrentDateIn) AND C.OPRID =%OperatorId AND B.EFF_STATUS= 'A' AND ((B.OTH_NAME_SORT_SRCH = ('%' %Concat %Upper(C.DESCR50)) %Concat '%') AND (B.EXT_ORG_ID = ( SELECT DISTINCT F.EXT_ORG_ID FROM PS_ORG_LOCATION F WHERE F.NUM1 = C.NUM1 AND F.POSTAL= C.SAD_BR_POSTAL_NLD)) OR (A.EXTERNAL_SYSTEM_ID = C.EXTERNAL_SYSTEM_ID)) AND A.EXTERNAL_SYSTEM = 'SBB' AND A.EFFDT = ( SELECT MAX(A1.EFFDT) FROM PS_SCC_ORG_EXT_KEY A1 WHERE A.EXT_ORG_ID =A1.EXT_ORG_ID AND A.EXTERNAL_SYSTEM = A1.EXTERNAL_SYSTEM AND A1.EFFDT <= %CurrentDateIn) AND C.SAD_BPV_TRANS_DTTM = ( SELECT MAX(C1.SAD_BPV_TRANS_DTTM) FROM PS_SAD_BPV_SBB_NLD C1 WHERE C1.OPRID =C.OPRID AND C.SAD_BPV_INDEX_ID = C1.SAD_BPV_INDEX_ID AND C.SAD_BPV_MSGUUID = C1.SAD_BPV_MSGUUID) AND C.SAD_BPV_INDEX_ID = D.SAD_BPV_INDEX_ID AND C.SAD_BPV_MSGUUID = D.SAD_BPV_MSGUUID
|