How to find the Customer data with email and phone no.
SELECT DISTINCT HP.PARTY_ID,
HP.PARTY_NAME CUSTOMER_NAME,
HP.PARTY_NUMBER,
HCA.CUST_ACCOUNT_ID,
HCA.ACCOUNT_NUMBER,
NAME ORG_NAME,
HCAS.CUST_ACCT_SITE_ID,
HPS.PARTY_SITE_NUMBER,
HCSU.SITE_USE_CODE,
HL.ADDRESS1,
HL.ADDRESS2,
HL.ADDRESS3,
HL.ADDRESS4,
HL.CITY,
HL.POSTAL_CODE,
HL.STATE,
HL.PROVINCE,
HL.COUNTY,
HL.COUNTRY,
HL.ADDRESS_STYLE,
APPS.XXPCL_CON_EMAIL_MO (1, HPS.PARTY_SITE_ID) EMAIL,
APPS.XXPCL_CON_EMAIL_MO (2, HPS.PARTY_SITE_ID) PHONE
FROM APPS.HZ_PARTIES HP,
APPS.HZ_PARTY_SITES HPS,
APPS.HZ_CUST_ACCOUNTS_ALL HCA,
APPS.HZ_CUST_ACCT_SITES_ALL HCAS,
APPS.HZ_CUST_SITE_USES_ALL HCSU,
APPS.HZ_LOCATIONS HL,
APPS.HR_OPERATING_UNITS HR
WHERE 1 = 1
AND HCAS.ORG_ID = HR.ORGANIZATION_ID
--AND SET_OF_BOOKS_ID = 2121
AND HP.PARTY_ID = HCA.PARTY_ID
AND HCA.CUST_ACCOUNT_ID = HCAS.CUST_ACCOUNT_ID(+)
AND HPS.PARTY_SITE_ID(+) = HCAS.PARTY_SITE_ID
AND HCAS.CUST_ACCT_SITE_ID = HCSU.CUST_ACCT_SITE_ID
AND HPS.LOCATION_ID = HL.LOCATION_ID(+)
AND HP.STATUS = 'A'
AND HCAS.STATUS = 'A'
ORDER BY HP.PARTY_NAME
------------------------------------------Function details------------------------
Note :- Function name :-----XXPCL_CON_EMAIL_MO
CREATE OR REPLACE FUNCTION APPS.XXPCL_CON_EMAIL_MO (P_NO_ID NUMBER ,P_PARTY_SITE_ID NUMBER) RETURN VARCHAR2
AS
-- FUNCTION NAME --XXPCL_CON_EMAIL_MO
--Techical Israr
--Technical.israr@gmail.com 05-oct-2018
V_EMAIL_ADDRESS VARCHAR2(100);
V_PHONE_NUMBER VARCHAR2(100);
V_COUNT NUMBER := 1;
CURSOR C1 IS
SELECT hcp.email_address,HPS.PARTY_SITE_ID
from hz_parties hz,
hz_party_sites hps,
hz_contact_points hcp
where 1=1
and hz.party_id=hps.party_id
and hps.party_site_id=hcp.owner_table_id
and HCP.status='A'
AND CONTACT_POINT_TYPE='EMAIL'
AND hps.party_site_id=P_PARTY_SITE_ID;
--and hz.party_id=494220
CURSOR C2
IS
SELECT A.PHONE_NUMBER
FROM HZ_CONTACT_POINTS A
WHERE 1 = 1 AND A.status = 'A' AND A.CONTACT_POINT_TYPE = 'PHONE' AND A.OWNER_TABLE_ID=P_PARTY_SITE_ID;
BEGIN
FOR I IN C1 LOOP
IF V_COUNT = 1 THEN
V_EMAIL_ADDRESS:= I.EMAIL_ADDRESS;
-- V_PHONE_NUMBER:=I.PHONE_NUMBER;
V_COUNT:= V_COUNT+1;
ELSE
V_EMAIL_ADDRESS:= V_EMAIL_ADDRESS||' / '||I.EMAIL_ADDRESS;
-- V_PHONE_NUMBER:=V_PHONE_NUMBER||' / '||I.PHONE_NUMBER;
END IF;
END LOOP;
FOR J IN C2
LOOP
IF V_COUNT = 1 THEN
--V_EMAIL_ADDRESS:= I.EMAIL_ADDRESS;
V_PHONE_NUMBER:=J.PHONE_NUMBER;
V_COUNT:= V_COUNT+1;
ELSE
--V_EMAIL_ADDRESS:= V_EMAIL_ADDRESS||' / '||I.EMAIL_ADDRESS;
V_PHONE_NUMBER:=V_PHONE_NUMBER||' / '||J.PHONE_NUMBER;
END IF;
END LOOP;
IF P_NO_ID =1 THEN
RETURN V_EMAIL_ADDRESS;
ELSIF P_NO_ID =2 THEN
RETURN V_PHONE_NUMBER;
ELSE RETURN NULL;
END IF;
EXCEPTION WHEN OTHERS THEN RETURN NULL;
END;
/
SELECT DISTINCT HP.PARTY_ID,
HP.PARTY_NAME CUSTOMER_NAME,
HP.PARTY_NUMBER,
HCA.CUST_ACCOUNT_ID,
HCA.ACCOUNT_NUMBER,
NAME ORG_NAME,
HCAS.CUST_ACCT_SITE_ID,
HPS.PARTY_SITE_NUMBER,
HCSU.SITE_USE_CODE,
HL.ADDRESS1,
HL.ADDRESS2,
HL.ADDRESS3,
HL.ADDRESS4,
HL.CITY,
HL.POSTAL_CODE,
HL.STATE,
HL.PROVINCE,
HL.COUNTY,
HL.COUNTRY,
HL.ADDRESS_STYLE,
APPS.XXPCL_CON_EMAIL_MO (1, HPS.PARTY_SITE_ID) EMAIL,
APPS.XXPCL_CON_EMAIL_MO (2, HPS.PARTY_SITE_ID) PHONE
FROM APPS.HZ_PARTIES HP,
APPS.HZ_PARTY_SITES HPS,
APPS.HZ_CUST_ACCOUNTS_ALL HCA,
APPS.HZ_CUST_ACCT_SITES_ALL HCAS,
APPS.HZ_CUST_SITE_USES_ALL HCSU,
APPS.HZ_LOCATIONS HL,
APPS.HR_OPERATING_UNITS HR
WHERE 1 = 1
AND HCAS.ORG_ID = HR.ORGANIZATION_ID
--AND SET_OF_BOOKS_ID = 2121
AND HP.PARTY_ID = HCA.PARTY_ID
AND HCA.CUST_ACCOUNT_ID = HCAS.CUST_ACCOUNT_ID(+)
AND HPS.PARTY_SITE_ID(+) = HCAS.PARTY_SITE_ID
AND HCAS.CUST_ACCT_SITE_ID = HCSU.CUST_ACCT_SITE_ID
AND HPS.LOCATION_ID = HL.LOCATION_ID(+)
AND HP.STATUS = 'A'
AND HCAS.STATUS = 'A'
ORDER BY HP.PARTY_NAME
------------------------------------------Function details------------------------
Note :- Function name :-----XXPCL_CON_EMAIL_MO
CREATE OR REPLACE FUNCTION APPS.XXPCL_CON_EMAIL_MO (P_NO_ID NUMBER ,P_PARTY_SITE_ID NUMBER) RETURN VARCHAR2
AS
-- FUNCTION NAME --XXPCL_CON_EMAIL_MO
--Techical Israr
--Technical.israr@gmail.com 05-oct-2018
V_EMAIL_ADDRESS VARCHAR2(100);
V_PHONE_NUMBER VARCHAR2(100);
V_COUNT NUMBER := 1;
CURSOR C1 IS
SELECT hcp.email_address,HPS.PARTY_SITE_ID
from hz_parties hz,
hz_party_sites hps,
hz_contact_points hcp
where 1=1
and hz.party_id=hps.party_id
and hps.party_site_id=hcp.owner_table_id
and HCP.status='A'
AND CONTACT_POINT_TYPE='EMAIL'
AND hps.party_site_id=P_PARTY_SITE_ID;
--and hz.party_id=494220
CURSOR C2
IS
SELECT A.PHONE_NUMBER
FROM HZ_CONTACT_POINTS A
WHERE 1 = 1 AND A.status = 'A' AND A.CONTACT_POINT_TYPE = 'PHONE' AND A.OWNER_TABLE_ID=P_PARTY_SITE_ID;
BEGIN
FOR I IN C1 LOOP
IF V_COUNT = 1 THEN
V_EMAIL_ADDRESS:= I.EMAIL_ADDRESS;
-- V_PHONE_NUMBER:=I.PHONE_NUMBER;
V_COUNT:= V_COUNT+1;
ELSE
V_EMAIL_ADDRESS:= V_EMAIL_ADDRESS||' / '||I.EMAIL_ADDRESS;
-- V_PHONE_NUMBER:=V_PHONE_NUMBER||' / '||I.PHONE_NUMBER;
END IF;
END LOOP;
FOR J IN C2
LOOP
IF V_COUNT = 1 THEN
--V_EMAIL_ADDRESS:= I.EMAIL_ADDRESS;
V_PHONE_NUMBER:=J.PHONE_NUMBER;
V_COUNT:= V_COUNT+1;
ELSE
--V_EMAIL_ADDRESS:= V_EMAIL_ADDRESS||' / '||I.EMAIL_ADDRESS;
V_PHONE_NUMBER:=V_PHONE_NUMBER||' / '||J.PHONE_NUMBER;
END IF;
END LOOP;
IF P_NO_ID =1 THEN
RETURN V_EMAIL_ADDRESS;
ELSIF P_NO_ID =2 THEN
RETURN V_PHONE_NUMBER;
ELSE RETURN NULL;
END IF;
EXCEPTION WHEN OTHERS THEN RETURN NULL;
END;
/
No comments:
Post a Comment