SELECT DISTINCT PKG.RB_PACKAGE_ID , TMPL.RB_TOKEN_ID FROM PS_RBC_PACKAGE_DFN PKG , PS_RBC_TEMPLAT_TKN TMPL , PS_RB_RECP_TERMS TRM WHERE PKG.EFF_STATUS = 'A' AND PKG.RB_TEMPLATE_ID = TMPL.RB_TEMPLATE_ID AND TMPL.RB_USE_TKNGRP = '0' AND TMPL.RB_TOKEN_ID = TRM.EOCF_LIB_TERM_ID UNION SELECT DISTINCT PKG2.RB_PACKAGE_ID , TRMG.RB_TOKEN_ID FROM PS_RBC_PACKAGE_DFN PKG2 , PS_RBC_TEMPLAT_TKN TMPL2 , PS_RBC_TKNGRP_DTL TRMG , PS_RB_RECP_TERMS TRM2 WHERE PKG2.EFF_STATUS = 'A' AND PKG2.RB_TEMPLATE_ID = TMPL2.RB_TEMPLATE_ID AND TMPL2.RB_USE_TKNGRP = '1' AND TMPL2.RB_TOKEN_ID = TRMG.RB_TKNGRP_ID AND TRMG.RB_TOKEN_ID = TRM2.EOCF_LIB_TERM_ID UNION SELECT DISTINCT PKG3.RB_PACKAGE_ID , SUB3.RB_TOKEN_ID FROM PS_RBC_PACKAGE_DFN PKG3 , PS_RBC_TEMPLAT_TKN TMPL3 , PS_RBC_SUBTMPL_TKN SUB3 , PS_RB_RECP_TERMS TRM3 WHERE PKG3.EFF_STATUS = 'A' AND PKG3.RB_TEMPLATE_ID = TMPL3.RB_TEMPLATE_ID AND TMPL3.RB_USE_TKNGRP = '2' AND TMPL3.RB_TOKEN_ID = SUB3.RB_SUBTMPLT_ID AND SUB3.RB_TOKEN_ID = TRM3.EOCF_LIB_TERM_ID UNION SELECT DISTINCT PKG4.RB_PACKAGE_ID , SUB4.RB_TOKEN_ID FROM PS_RBC_PACKAGE_DFN PKG4 , PS_RBC_TEMPLAT_TKN TMPL4 , PS_RBC_SUBTMPL_TKN SUB4 , PS_RBC_TKNGRP_DTL TRMG4 , PS_RB_RECP_TERMS TRM4 WHERE PKG4.EFF_STATUS = 'A' AND PKG4.RB_TEMPLATE_ID = TMPL4.RB_TEMPLATE_ID AND TMPL4.RB_USE_TKNGRP = '2' AND TMPL4.RB_TOKEN_ID = SUB4.RB_SUBTMPLT_ID AND SUB4.RB_TOKEN_ID = TRMG4.RB_TKNGRP_ID AND TRMG4.RB_TOKEN_ID = TRM4.EOCF_LIB_TERM_ID
|