59: END;
60:
61: FUNCTION is_cust_role_in_ct_gt
62: ---------------------------------------------------------------------------------------
63: -- Return Y if the P_CUST_ACCOUNR_ROLE_ID is already inserted in HZ_MATCHED_CONTACTS_GT
64: -- Otherwise N
65: ---------------------------------------------------------------------------------------
66: ( p_ctx_id IN NUMBER,
67: p_cust_account_role_id IN NUMBER,
70: RETURN VARCHAR2
71: IS
72: CURSOR c1 IS
73: SELECT 'Y'
74: FROM hz_matched_contacts_gt a,
75: hz_cust_account_roles b
76: WHERE a.search_context_id = p_ctx_id
77: AND -a.party_id = p_cust_account_id
78: AND -a.org_contact_id = p_cust_account_role_id
328: CURSOR c1 IS
329: SELECT party_id,
330: org_contact_id,
331: score
332: FROM hz_matched_contacts_gt
333: WHERE search_context_id = p_ctx_id
334: AND score >= 0;
335: lrec c1%ROWTYPE;
336: BEGIN
407: f.score pty_score,
408: d.cust_account_role_id,
409: d.cust_account_id,
410: d.cust_acct_site_id
411: FROM hz_matched_contacts_gt a,
412: hz_org_contacts b,
413: hz_relationships c,
414: hz_cust_account_roles d,
415: hz_cust_accounts e,
441: IF c1%NOTFOUND THEN
442: NULL;
443: ELSE
444: ------------------------------------------------------
445: --{ Insert Cust Account Role in HZ_MATCHED_CONTACTS_GT
446: ------------------------------------------------------
447: lyn := is_cust_role_in_ct_gt( p_ctx_id => p_ctx_id,
448: p_cust_account_role_id => lrec.cust_account_role_id,
449: p_cust_account_id => lrec.cust_account_id,
456: l_score := -1;
457: ELSE
458: l_score := -lrec.ct_score;
459: END IF;
460: INSERT INTO hz_matched_contacts_gt
461: ( PARTY_ID , ORG_CONTACT_ID , SCORE , SEARCH_CONTEXT_ID) VALUES
462: ( -lrec.cust_account_id, -lrec.cust_account_role_id, l_score , p_ctx_id );
463:
464: ------------------------------------------------
492: l_score := -1;
493: ELSE
494: l_score := -lrec.ct_score;
495: END IF;
496: INSERT INTO hz_matched_contacts_gt
497: ( PARTY_ID , ORG_CONTACT_ID , SCORE , SEARCH_CONTEXT_ID) VALUES
498: ( -lrec.cust_account_id, -lrec.cust_account_role_id, l_score , p_ctx_id );
499:
500: ---------------------------------------------------------
701: RETURN VARCHAR2
702: IS
703: CURSOR c1 IS
704: SELECT 'Y'
705: FROM hz_matched_contacts_gt a,
706: hz_org_contacts b
707: WHERE a.search_context_id = p_ctx_id
708: AND NVL(a.score,0) >= 0
709: AND a.org_contact_id = b.org_contact_id
843: AND party_id = p_party_id;
844:
845: CURSOR c2 IS
846: SELECT 'Y'
847: FROM hz_matched_contacts_gt
848: WHERE search_context_id = p_ctx_id
849: AND NVL(score,0) >= 0
850: AND party_id = p_party_id;
851: /*