SELECT DISTINCT B.RECNAME , B.FIELDNAME ,C1.LANGUAGE_CD , C1.LONGNAME FROM PS_EODP_RECFLDDB B , PSDBFLDLABL C , PSDBFLDLABLLANG C1 WHERE B.FIELDNAME = C.FIELDNAME AND C.DEFAULT_LABEL = 1 AND C1.FIELDNAME=C.FIELDNAME and C1.LABEL_ID=C.LABEL_ID union select distinct A.RECNAME,A.FIELDNAME,C1.LANGUAGE_CD,C1.LONGNAME from PSRECFIELDDB A, PSDBFLDLABL C, PSDBFLDLABLLANG C1 where A.FIELDNAME=C.FIELDNAME and C.DEFAULT_LABEL=1 AND C1.FIELDNAME=C.FIELDNAME and C1.LABEL_ID=C.LABEL_ID and exists (select 'X' from PS_EODP_RECFLDDB1 X where X.RECNAME_PARENT=A.RECNAME_PARENT and X.RECNAME<>A.RECNAME and X.RECNAME_PARENT<>' ' and X.FIELDNAME=A.FIELDNAME) union select distinct A.RECNAME,A.FIELDNAME,C1.LANGUAGE_CD,C1.LONGNAME from PSRECFIELDDB A, PSDBFLDLABL C,PSDBFLDLABLLANG C1 where A.FIELDNAME=C.FIELDNAME and C.DEFAULT_LABEL=1 AND C1.FIELDNAME=C.FIELDNAME and C1.LABEL_ID=C.LABEL_ID and not exists (select 'X' from PS_EODP_RECFLDDB1 X where X.RECNAME=A.RECNAME) and exists(select 'X' from PS_EODP_RECFLDDB1 X1 where X1.RECNAME_PARENT=A.RECNAME_PARENT and X1.FIELDNAME=A.FIELDNAME)
|