Wednesday, January 18, 2017

Query to find customer name from account ID in CCB

This query help you to retrieve customer name from his account id

SELECT CPN.ENTITY_NAME
FROM CI_ACCT CA
INNER JOIN CI_ACCT_PER CAP
ON (CAP.ACCT_ID = CA.ACCT_ID
AND CA.ACCT_ID = '0002000000' -- Put your account id here
AND TRIM(CAP.ACCT_REL_TYPE_CD) = 'MAIN')-- only to retrieve main customers there may be one or many child
INNER JOIN CI_PER CP
ON (CP.PER_ID = CAP.PER_ID)
INNER JOIN CI_PER_NAME CPN
ON (CPN.PER_ID = CP.PER_ID
AND TRIM(CPN.NAME_TYPE_FLG) = 'PRIM');--only to retrieve primary name may or may not there are many

No comments:

Post a Comment