DBA Data[Home] [Help]

APPS.HZ_DQM_MR_PVT SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 62

    select sum(sc) sum_score , max(sc) max_score , min(sc) min_score
    from
    (select  entity_name ename, sum(score) sc
     from hz_trans_attributes_vl a, hz_match_rule_secondary s
     where s.match_rule_id = p_match_rule_id
     and s.attribute_id = a.attribute_id
     group by entity_name
     order by sum(score) desc
     );
Line: 92

    select match_score
    from hz_match_rules_vl
    where match_rule_id = p_match_rule_id;
Line: 110

    select auto_merge_score
    from hz_match_rules_vl
    where match_rule_id = p_match_rule_id;
Line: 128

    select match_all_flag
    from hz_match_rules_vl
    where match_rule_id = p_match_rule_id;
Line: 147

    SELECT count(1) into filter_count
    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
    where  p.match_rule_id=p_match_rule_id
    and p.attribute_id=a.attribute_id
    and a.entity_name = 'PARTY'
    and p.filter_flag = 'Y';
Line: 168

    SELECT count(1) into filter_count
    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
    where  p.match_rule_id=p_match_rule_id
    and p.attribute_id=a.attribute_id
    and a.entity_name = p_entity_name
    and p.filter_flag = 'Y';
Line: 189

        SELECT s.attribute_id
        FROM HZ_MATCH_RULE_SECONDARY s, HZ_TRANS_ATTRIBUTES_VL a
        where a.attribute_id=s.attribute_id
        and s.match_rule_id=p_match_rule_id
        and a.entity_name = p_entity_name
        )
        LOOP
            temp := TRUE ;
Line: 229

FUNCTION get_insert_threshold ( p_match_rule_id  NUMBER)
return number
IS
CURSOR entity_cur IS
                select  entity_name, sum(score) sc
                from hz_trans_attributes_vl a, hz_match_rule_secondary s
                where s.match_rule_id = p_match_rule_id
                and s.attribute_id = a.attribute_id
                group by entity_name
                order by sum(score) desc ;
Line: 245

insert_threshold number;
Line: 251

    select match_score, match_all_flag into match_score, match_all_flag
    from hz_match_rules_vl
    where match_rule_id = p_match_rule_id;
Line: 263

    insert_threshold := match_score ;
Line: 304

                    insert_threshold := insert_threshold - entity_cur_rec.sc ;
Line: 314

                            insert_threshold := insert_threshold - entity_cur_rec.sc ;
Line: 320

                           insert_threshold := insert_threshold - entity_cur_rec.sc ;
Line: 329

                   insert_threshold := insert_threshold - entity_cur_rec.sc ;
Line: 335

        return insert_threshold;
Line: 358

    l('PROCEDURE tca_join_entities(trap_explosion in varchar2, rows_in_chunk in number,inserted_duplicates out number);');
Line: 409

    l('PROCEDURE tca_join_entities(trap_explosion in varchar2, rows_in_chunk in number, inserted_duplicates out number)');
Line: 412

    temp := get_insert_threshold(p_match_rule_id);
Line: 413

    l('    x_insert_threshold number := ' || temp || ';');
Line: 417

    l('FND_FILE.put_line(FND_FILE.log,''Start time of insert of Parties ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 418

    l('insert into hz_dup_results(fid, tid, ord_fid, ord_tid, score)');
Line: 419

    l('select f, t, least(f,t), greatest(f,t), sum(score) score  from (');
Line: 437

    l('             inserted_duplicates := -1;');
Line: 451

PROCEDURE gen_insert_template_tca(
       p_table VARCHAR2,
       p_match_rule_id NUMBER,
       p_entity VARCHAR2,
       p_match_all_flag VARCHAR2
)
IS
FIRST BOOLEAN ;
Line: 473

        l('select f, t, max(score) score from (');
Line: 476

     l('select /*+ ORDERED */ s1.party_id f, s2.party_id t,');
Line: 480

   SELECT count(1) into outer_row_count
   FROM HZ_MATCH_RULE_SECONDARY s, HZ_TRANS_ATTRIBUTES_VL a
   where a.attribute_id=s.attribute_id
   and s.match_rule_id=p_match_rule_id
   and a.entity_name = p_entity;
Line: 490

          SELECT score,s.attribute_id , secondary_attribute_id
          FROM HZ_MATCH_RULE_SECONDARY s, HZ_TRANS_ATTRIBUTES_VL a
          where a.attribute_id=s.attribute_id
          and s.match_rule_id=p_match_rule_id
          and a.entity_name = p_entity)
          LOOP
              outer_row_counter := outer_row_counter + 1;
Line: 500

                      SELECT round(transformation_weight/100*attrs.score) score, staged_attribute_column
                      FROM hz_secondary_trans st, hz_trans_functions_vl f
                      where f.function_id=st.function_id
                      and st.secondary_attribute_id = attrs.secondary_attribute_id
                      order by transformation_weight desc)
                    LOOP
                                inner_row_counter := inner_row_counter + 1;
Line: 546

     l('and exists(SELECT 1 from hz_staged_parties q where q.party_id = s2.party_id and nvl(q.status,''A'') = ''A'') ');
Line: 563

    SELECT primary_attribute_id
    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
    where  p.match_rule_id=p_match_rule_id
    and p.attribute_id=a.attribute_id
    and a.entity_name = p_entity
    and nvl(p.filter_flag,'N') = 'N' )
   LOOP
                -- between attributes
                IF FIRST1
                THEN
                   FIRST1 := FALSE;
Line: 586

               FOR trans in ( SELECT staged_attribute_column
                  FROM hz_primary_trans pt, hz_trans_functions_vl f
                  where f.function_id = pt.function_id
                  and pt.primary_attribute_id = attrs.primary_attribute_id
               )
               LOOP
                    IF FIRST
                    THEN
                        l('-- do an or between all the transformations of an attribute -- ');
Line: 617

                SELECT primary_attribute_id
                FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
                where  p.match_rule_id=p_match_rule_id
                and p.attribute_id=a.attribute_id
                and a.entity_name = p_entity
                and nvl(p.filter_flag,'N') = 'Y' )
               LOOP
                          IF FIRST1
                          THEN
                               FIRST1 := FALSE;
Line: 634

                           FOR trans in ( SELECT staged_attribute_column
                              FROM hz_primary_trans pt, hz_trans_functions_vl f
                              where f.function_id = pt.function_id
                              and pt.primary_attribute_id = attrs.primary_attribute_id
                           )
                           LOOP
                                IF FIRST
                                THEN
                                    l('-- do an or between all the transformations of an attribute -- ');
Line: 676

PROCEDURE gen_insert_footer_tca(p_match_rule_id number)
IS
FIRST1 boolean;
Line: 689

                   l('SELECT 1 FROM HZ_STAGED_PARTIES p1, HZ_STAGED_PARTIES p2');
Line: 693

                    SELECT primary_attribute_id
                    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
                    where  p.match_rule_id=p_match_rule_id
                    and p.attribute_id=a.attribute_id
                    and a.entity_name = 'PARTY'
                    and nvl(p.filter_flag,'N') = 'Y' )
                   LOOP
                              IF FIRST1
                              THEN
                                   FIRST1 := FALSE;
Line: 709

                               FOR trans in ( SELECT staged_attribute_column
                                  FROM hz_primary_trans pt, hz_trans_functions_vl f
                                  where f.function_id = pt.function_id
                                  and pt.primary_attribute_id = attrs.primary_attribute_id
                               )
                               LOOP
                                    IF FIRST
                                    THEN
                                        l('-- do an or between all the transformations of an attribute -- ');
Line: 741

    IF get_insert_threshold(p_match_rule_id) > 0
    THEN
        l('having sum(score) >= x_insert_threshold');
Line: 747

    l('inserted_duplicates := (SQL%ROWCOUNT);');
Line: 748

    l('FND_FILE.put_line(FND_FILE.log,''Number of parties inserted ''||SQL%ROWCOUNT);');
Line: 749

    l('FND_FILE.put_line(FND_FILE.log,''End time of insert ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 759

PROCEDURE gen_update_template_tca (
        p_table VARCHAR2,
        p_match_rule_id NUMBER,
        p_entity VARCHAR2,
        p_match_all_flag VARCHAR2
)
IS
FIRST BOOLEAN ;
Line: 777

   l('FND_FILE.put_line(FND_FILE.log,'||''''|| 'Beginning update of Parties on the basis of ' || p_entity || ''''|| ');');
Line: 778

   l('FND_FILE.put_line(FND_FILE.log,''Start time of update ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 784

        l('select f, t, max(score) score from (');
Line: 787

   l(' select /*+ ORDERED */ s1.party_id f, s2.party_id t,');
Line: 790

   SELECT count(1) into outer_row_count
   FROM HZ_MATCH_RULE_SECONDARY s, HZ_TRANS_ATTRIBUTES_VL a
   where a.attribute_id=s.attribute_id
   and s.match_rule_id=p_match_rule_id
   and a.entity_name = p_entity;
Line: 801

            SELECT score,s.attribute_id , secondary_attribute_id
            FROM HZ_MATCH_RULE_SECONDARY s, HZ_TRANS_ATTRIBUTES_VL a
            where a.attribute_id=s.attribute_id
            and s.match_rule_id=p_match_rule_id
            and a.entity_name = p_entity)
            LOOP
                outer_row_counter := outer_row_counter + 1;
Line: 811

                        SELECT round(transformation_weight/100*attrs.score) score, staged_attribute_column
                        FROM hz_secondary_trans st, hz_trans_functions_vl f
                        where f.function_id=st.function_id
                        and st.secondary_attribute_id = attrs.secondary_attribute_id
                        order by transformation_weight desc)
                      LOOP
                                  inner_row_counter := inner_row_counter + 1;
Line: 851

    SELECT primary_attribute_id
    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
    where  p.match_rule_id=p_match_rule_id
    and p.attribute_id=a.attribute_id
    and a.entity_name = p_entity
    and nvl(p.filter_flag,'N') = 'N' )
   LOOP
                -- between attributes
                IF FIRST1
                THEN
                   FIRST1 := FALSE;
Line: 874

               FOR trans in ( SELECT staged_attribute_column
                  FROM hz_primary_trans pt, hz_trans_functions_vl f
                  where f.function_id = pt.function_id
                  and pt.primary_attribute_id = attrs.primary_attribute_id
               )
               LOOP
                    IF FIRST
                    THEN
                        l('-- do an or between all the transformations of an attribute -- ');
Line: 903

    SELECT primary_attribute_id
    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
    where  p.match_rule_id=p_match_rule_id
    and p.attribute_id=a.attribute_id
    and a.entity_name = p_entity
    and nvl(p.filter_flag,'N') = 'Y' )
   LOOP
                -- between attributes
                IF FIRST1
                THEN
                   FIRST1 := FALSE;
Line: 922

               FOR trans in ( SELECT staged_attribute_column
                  FROM hz_primary_trans pt, hz_trans_functions_vl f
                  where f.function_id = pt.function_id
                  and pt.primary_attribute_id = attrs.primary_attribute_id
               )
               LOOP
                    IF FIRST
                    THEN
                        l('-- do an or between all the transformations of an attribute -- ');
Line: 957

   l('HZ_DQM_DUP_ID_PKG.update_hz_dup_results(x_ent_cur);');
Line: 959

   l('FND_FILE.put_line(FND_FILE.log,''Number of parties updated ''||SQL%ROWCOUNT);');
Line: 960

   l('FND_FILE.put_line(FND_FILE.log,''End time to update ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 961

   l('FND_FILE.put_line(FND_FILE.log,'||''''|| 'Ending update of Parties on the basis of ' || p_entity || ''''|| ');');
Line: 976

                select entity_name, entity_table_name, sc, att_flag
                from
                        (select  entity_name, decode(entity_name,
                                       'PARTY','HZ_STAGED_PARTIES',
                                       'PARTY_SITES', 'HZ_STAGED_PARTY_SITES',
                                       'CONTACTS','HZ_STAGED_CONTACTS',
                                       'CONTACT_POINTS', 'HZ_STAGED_CONTACT_POINTS') entity_table_name,
                                       sum(score) sc, 'S' att_flag
                        from hz_trans_attributes_vl a, hz_match_rule_secondary s
                        where s.match_rule_id = p_match_rule_id
                        and s.attribute_id = a.attribute_id
                        group by entity_name
                        union all
                        select  entity_name, decode(entity_name,
                                       'PARTY','HZ_STAGED_PARTIES',
                                       'PARTY_SITES', 'HZ_STAGED_PARTY_SITES',
                                       'CONTACTS','HZ_STAGED_CONTACTS',
                                       'CONTACT_POINTS', 'HZ_STAGED_CONTACT_POINTS') entity_table_name,
                                       0 sc, 'P' att_flag
                        from hz_trans_attributes_vl a, hz_match_rule_primary p
                        where p.match_rule_id = p_match_rule_id
                        and p.attribute_id = a.attribute_id
                        group by entity_name
                )
                where att_flag = p_att_flag
                order by sc desc ;
Line: 1008

insert_stmt_is_open boolean;
Line: 1013

    select match_score, match_all_flag into threshold, match_all_flag
    from hz_match_rules_vl
    where match_rule_id = p_match_rule_id;
Line: 1065

    insert_stmt_is_open := false;
Line: 1087

                    gen_insert_template_tca(entity_cur_rec.entity_table_name, p_match_rule_id, entity_cur_rec.entity_name,
                                                                                               match_all_flag);
Line: 1089

                    insert_stmt_is_open := true;
Line: 1107

                    gen_insert_template_tca(entity_cur_rec.entity_table_name, p_match_rule_id, entity_cur_rec.entity_name,
                                                                                               match_all_flag);
Line: 1110

                    IF insert_stmt_is_open
                    THEN
                        gen_insert_footer_tca(p_match_rule_id);
Line: 1113

                        insert_stmt_is_open := false;
Line: 1115

                    gen_update_template_tca(entity_cur_rec.entity_table_name, p_match_rule_id, entity_cur_rec.entity_name,
                                                                                               match_all_flag);
Line: 1127

                            gen_insert_template_tca(entity_cur_rec.entity_table_name, p_match_rule_id, entity_cur_rec.entity_name,
                                                                                                       match_all_flag);
Line: 1130

                            IF insert_stmt_is_open
                            THEN
                                gen_insert_footer_tca(p_match_rule_id);
Line: 1133

                                insert_stmt_is_open := false;
Line: 1135

                            gen_update_template_tca(entity_cur_rec.entity_table_name, p_match_rule_id, entity_cur_rec.entity_name,
                                                                                                       match_all_flag);
Line: 1143

                            gen_insert_template_tca(entity_cur_rec.entity_table_name, p_match_rule_id, entity_cur_rec.entity_name,
                                                                                                       match_all_flag);
Line: 1146

                            IF insert_stmt_is_open
                            THEN
                                gen_insert_footer_tca(p_match_rule_id);
Line: 1149

                                insert_stmt_is_open := false;
Line: 1151

                            gen_update_template_tca(entity_cur_rec.entity_table_name, p_match_rule_id, entity_cur_rec.entity_name,
                                                                                                       match_all_flag);
Line: 1162

                    gen_insert_template_tca(entity_cur_rec.entity_table_name, p_match_rule_id, entity_cur_rec.entity_name,
                                                                                               match_all_flag);
Line: 1165

                    IF insert_stmt_is_open
                    THEN
                        gen_insert_footer_tca(p_match_rule_id);
Line: 1168

                        insert_stmt_is_open := false;
Line: 1170

                    gen_update_template_tca(entity_cur_rec.entity_table_name, p_match_rule_id, entity_cur_rec.entity_name,
                                                                                               match_all_flag);
Line: 1179

        IF insert_stmt_is_open
        THEN
            gen_insert_footer_tca(p_match_rule_id);
Line: 1182

            insert_stmt_is_open := false;
Line: 1230

    temp := get_insert_threshold(p_match_rule_id);
Line: 1231

    l('x_insert_threshold number := ' || temp || ';');
Line: 1235

    l('FND_FILE.put_line(FND_FILE.log,''Start time of insert of Parties ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 1236

    l('insert into hz_imp_dup_parties(party_id,dup_party_id, score, party_osr, party_os, batch_id, auto_merge_flag');
Line: 1237

    l(',created_by,creation_date,last_update_login,last_update_date,last_updated_by)');
Line: 1238

    l('select f, t, sum(score) sc, party_osr, party_os, p_batch_id, ''N'' ');
Line: 1239

    l(',hz_utility_v2pub.created_by,hz_utility_v2pub.creation_date,hz_utility_v2pub.last_update_login');
Line: 1240

    l(',hz_utility_v2pub.last_update_date,hz_utility_v2pub.last_updated_by');
Line: 1270

PROCEDURE gen_insert_template_int_tca(
       s_table VARCHAR2,
       p_table VARCHAR2,
       p_match_rule_id NUMBER,
       p_entity VARCHAR2,
       p_match_all_flag VARCHAR2
)
IS
FIRST BOOLEAN ;
Line: 1288

        l('select f, t, max(score) score, party_osr, party_os from (');
Line: 1291

     l('select /*+ USE_CONCAT */ s1.party_id f, s2.party_id t,');
Line: 1295

   SELECT count(1) into outer_row_count
   FROM HZ_MATCH_RULE_SECONDARY s, HZ_TRANS_ATTRIBUTES_VL a
   where a.attribute_id=s.attribute_id
   and s.match_rule_id=p_match_rule_id
   and a.entity_name = p_entity;
Line: 1305

            SELECT score,s.attribute_id , secondary_attribute_id
            FROM HZ_MATCH_RULE_SECONDARY s, HZ_TRANS_ATTRIBUTES_VL a
            where a.attribute_id=s.attribute_id
            and s.match_rule_id=p_match_rule_id
            and a.entity_name = p_entity)
            LOOP
                outer_row_counter := outer_row_counter + 1;
Line: 1315

                        SELECT round(transformation_weight/100*attrs.score) score, staged_attribute_column
                        FROM hz_secondary_trans st, hz_trans_functions_vl f
                        where f.function_id=st.function_id
                        and st.secondary_attribute_id = attrs.secondary_attribute_id
                        order by transformation_weight desc)
                      LOOP
                                  inner_row_counter := inner_row_counter + 1;
Line: 1380

     l('and exists(SELECT 1 from hz_staged_parties q where q.party_id = s2.party_id and nvl(q.status,''A'') = ''A'') ');
Line: 1392

    SELECT primary_attribute_id
    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
    where  p.match_rule_id=p_match_rule_id
    and p.attribute_id=a.attribute_id
    and a.entity_name = p_entity
    and nvl(p.filter_flag,'N') = 'N' )
   LOOP
                -- between attributes
                IF FIRST1
                THEN
                   FIRST1 := FALSE;
Line: 1415

               FOR trans in ( SELECT staged_attribute_column
                  FROM hz_primary_trans pt, hz_trans_functions_vl f
                  where f.function_id = pt.function_id
                  and pt.primary_attribute_id = attrs.primary_attribute_id
               )
               LOOP
                    IF FIRST
                    THEN
                        l('-- do an or between all the transformations of an attribute -- ');
Line: 1448

                SELECT primary_attribute_id
                FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
                where  p.match_rule_id=p_match_rule_id
                and p.attribute_id=a.attribute_id
                and a.entity_name = p_entity
                and nvl(p.filter_flag,'N') = 'Y' )
               LOOP
                            -- between attributes
                            IF FIRST1
                            THEN
                               FIRST1 := FALSE;
Line: 1466

                           FOR trans in ( SELECT staged_attribute_column
                              FROM hz_primary_trans pt, hz_trans_functions_vl f
                              where f.function_id = pt.function_id
                              and pt.primary_attribute_id = attrs.primary_attribute_id
                           )
                           LOOP
                                IF FIRST
                                THEN
                                    l('-- do an or between all the transformations of an attribute -- ');
Line: 1505

PROCEDURE gen_dl_insert_template_int_tca(
       s_table VARCHAR2,
       p_table VARCHAR2,
       p_match_rule_id NUMBER,
       p_entity VARCHAR2,
       p_entity_id_name VARCHAR2,
       p_entity_osr_name VARCHAR2,
       p_entity_os_name VARCHAR2,
       p_match_all_flag VARCHAR2
)
IS
FIRST BOOLEAN ;
Line: 1526

   l('FND_FILE.put_line(FND_FILE.log,'||''''|| 'Beginning insert  of ' || p_entity || ''''|| ');');
Line: 1527

   l('FND_FILE.put_line(FND_FILE.log,''Start time of insert ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 1530

   l('insert into hz_imp_dup_details(party_id, score, party_osr, party_os, batch_id, entity, record_id, record_osr, record_os, dup_record_id');
Line: 1531

   l(',created_by,creation_date,last_update_login,last_update_date,last_updated_by)');
Line: 1532

   l('select /*+ USE_CONCAT */ s1.party_id f,');
Line: 1534

   SELECT count(1) into outer_row_count
   FROM HZ_MATCH_RULE_SECONDARY s, HZ_TRANS_ATTRIBUTES_VL a
   where a.attribute_id=s.attribute_id
   and s.match_rule_id=p_match_rule_id
   and a.entity_name = p_entity;
Line: 1544

              SELECT score,s.attribute_id , secondary_attribute_id
              FROM HZ_MATCH_RULE_SECONDARY s, HZ_TRANS_ATTRIBUTES_VL a
              where a.attribute_id=s.attribute_id
              and s.match_rule_id=p_match_rule_id
              and a.entity_name = p_entity)
              LOOP
                  outer_row_counter := outer_row_counter + 1;
Line: 1554

                          SELECT round(transformation_weight/100*attrs.score) score, staged_attribute_column
                          FROM hz_secondary_trans st, hz_trans_functions_vl f
                          where f.function_id=st.function_id
                          and st.secondary_attribute_id = attrs.secondary_attribute_id
                          order by transformation_weight desc)
                        LOOP
                                    inner_row_counter := inner_row_counter + 1;
Line: 1586

   l(',hz_utility_v2pub.created_by,hz_utility_v2pub.creation_date,hz_utility_v2pub.last_update_login');
Line: 1587

   l(',hz_utility_v2pub.last_update_date,hz_utility_v2pub.last_updated_by');
Line: 1598

    SELECT primary_attribute_id
    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
    where  p.match_rule_id=p_match_rule_id
    and p.attribute_id=a.attribute_id
    and a.entity_name = p_entity
    and nvl(p.filter_flag,'N') = 'N' )
   LOOP
                -- between attributes
                IF FIRST1
                THEN
                   FIRST1 := FALSE;
Line: 1621

               FOR trans in ( SELECT staged_attribute_column
                  FROM hz_primary_trans pt, hz_trans_functions_vl f
                  where f.function_id = pt.function_id
                  and pt.primary_attribute_id = attrs.primary_attribute_id
               )
               LOOP
                    IF FIRST
                    THEN
                        l('-- do an or between all the transformations of an attribute -- ');
Line: 1650

    SELECT primary_attribute_id
    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
    where  p.match_rule_id=p_match_rule_id
    and p.attribute_id=a.attribute_id
    and a.entity_name = p_entity
    and nvl(p.filter_flag,'N') = 'Y'
    and HZ_IMP_DQM_STAGE.EXIST_COL(a.attribute_name, a.entity_name ) = 'Y'
    )
   LOOP
                -- between attributes
                IF FIRST1
                THEN
                   FIRST1 := FALSE;
Line: 1669

               FOR trans in ( SELECT staged_attribute_column
                  FROM hz_primary_trans pt, hz_trans_functions_vl f
                  where f.function_id = pt.function_id
                  and pt.primary_attribute_id = attrs.primary_attribute_id
               )
               LOOP
                    IF FIRST
                    THEN
                        l('-- do an or between all the transformations of an attribute -- ');
Line: 1702

l('--------UPDATE DQM ACTION FLAG IN ' || p_entity ||' INTERFACE/STAGING TABLES --------------');
Line: 1704

l('select distinct a.record_osr, a.record_os');
Line: 1708

l('HZ_DQM_DUP_ID_PKG.update_detail_dqm_action_flag(''' ||p_entity ||''',p_batch_id, x_ent_cur);');
Line: 1710

l('FND_FILE.put_line(FND_FILE.log,'||''''|| 'Ending insert of ' || p_entity || ''''|| ');');
Line: 1711

l('FND_FILE.put_line(FND_FILE.log,''Number of records inserted ''||SQL%ROWCOUNT);');
Line: 1712

l('FND_FILE.put_line(FND_FILE.log,''End time to insert ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 1721

PROCEDURE gen_insert_footer_int_tca(p_match_rule_id number)
IS
FIRST1 boolean;
Line: 1733

                   l('SELECT 1 FROM HZ_SRCH_PARTIES p1, HZ_STAGED_PARTIES p2');
Line: 1738

                    SELECT primary_attribute_id
                    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
                    where  p.match_rule_id=p_match_rule_id
                    and p.attribute_id=a.attribute_id
                    and a.entity_name = 'PARTY'
                    and nvl(p.filter_flag,'N') = 'Y'
                    and HZ_IMP_DQM_STAGE.EXIST_COL(a.attribute_name, a.entity_name ) = 'Y'
                    )
                   LOOP
                              IF FIRST1
                              THEN
                                   FIRST1 := FALSE;
Line: 1756

                               FOR trans in ( SELECT staged_attribute_column
                                  FROM hz_primary_trans pt, hz_trans_functions_vl f
                                  where f.function_id = pt.function_id
                                  and pt.primary_attribute_id = attrs.primary_attribute_id
                               )
                               LOOP
                                     IF FIRST
                                     THEN
                                        l('-- do an or between all the transformations of an attribute -- ');
Line: 1788

    IF get_insert_threshold(p_match_rule_id) > 0
    THEN
        l('having sum(score) >= x_insert_threshold');
Line: 1794

    l('FND_FILE.put_line(FND_FILE.log,''Number of parties inserted ''||SQL%ROWCOUNT);');
Line: 1795

    l('FND_FILE.put_line(FND_FILE.log,''End time of insert ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 1802

PROCEDURE gen_update_template_int_tca (
        s_table VARCHAR2,
        p_table VARCHAR2,
        p_match_rule_id NUMBER,
        p_entity VARCHAR2,
        p_match_all_flag VARCHAR2
)
IS
FIRST BOOLEAN ;
Line: 1821

   l('FND_FILE.put_line(FND_FILE.log,'||''''|| 'Beginning update of Parties on the basis of ' || p_entity || ''''|| ');');
Line: 1822

   l('FND_FILE.put_line(FND_FILE.log,''Start time of update ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 1825

   l('select f,t,max(score) from (');
Line: 1826

   l(' select /*+ USE_CONCAT */ s1.party_id f, s2.party_id t,');
Line: 1829

    SELECT count(1) into outer_row_count
   FROM HZ_MATCH_RULE_SECONDARY s, HZ_TRANS_ATTRIBUTES_VL a
   where a.attribute_id=s.attribute_id
   and s.match_rule_id=p_match_rule_id
   and a.entity_name = p_entity;
Line: 1840

            SELECT score,s.attribute_id , secondary_attribute_id
            FROM HZ_MATCH_RULE_SECONDARY s, HZ_TRANS_ATTRIBUTES_VL a
            where a.attribute_id=s.attribute_id
            and s.match_rule_id=p_match_rule_id
            and a.entity_name = p_entity)
            LOOP
                outer_row_counter := outer_row_counter + 1;
Line: 1850

                        SELECT round(transformation_weight/100*attrs.score) score, staged_attribute_column
                        FROM hz_secondary_trans st, hz_trans_functions_vl f
                        where f.function_id=st.function_id
                        and st.secondary_attribute_id = attrs.secondary_attribute_id
                        order by transformation_weight desc)
                      LOOP
                                  inner_row_counter := inner_row_counter + 1;
Line: 1890

    SELECT primary_attribute_id
    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
    where  p.match_rule_id=p_match_rule_id
    and p.attribute_id=a.attribute_id
    and a.entity_name = p_entity
    and nvl(p.filter_flag,'N') = 'N' )
   LOOP
                -- between attributes
                IF FIRST1
                THEN
                   FIRST1 := FALSE;
Line: 1913

               FOR trans in ( SELECT staged_attribute_column
                  FROM hz_primary_trans pt, hz_trans_functions_vl f
                  where f.function_id = pt.function_id
                  and pt.primary_attribute_id = attrs.primary_attribute_id
               )
               LOOP
                    IF FIRST
                    THEN
                        l('-- do an or between all the transformations of an attribute -- ');
Line: 1942

    SELECT primary_attribute_id
    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
    where  p.match_rule_id=p_match_rule_id
    and p.attribute_id=a.attribute_id
    and a.entity_name = p_entity
    and nvl(p.filter_flag,'N') = 'Y'
    and HZ_IMP_DQM_STAGE.EXIST_COL(a.attribute_name, a.entity_name ) = 'Y'
    )
   LOOP
                -- between attributes
                IF FIRST1
                THEN
                   FIRST1 := FALSE;
Line: 1961

               FOR trans in ( SELECT staged_attribute_column
                  FROM hz_primary_trans pt, hz_trans_functions_vl f
                  where f.function_id = pt.function_id
                  and pt.primary_attribute_id = attrs.primary_attribute_id
               )
               LOOP
                    IF FIRST
                    THEN
                        l('-- do an or between all the transformations of an attribute -- ');
Line: 1987

   l('HZ_DQM_DUP_ID_PKG.update_hz_imp_dup_parties(p_batch_id, x_ent_cur);');
Line: 1989

   l('FND_FILE.put_line(FND_FILE.log,''Number of parties updated ''||SQL%ROWCOUNT);');
Line: 1990

   l('FND_FILE.put_line(FND_FILE.log,''End time to update ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 1991

   l('FND_FILE.put_line(FND_FILE.log,'||''''|| 'Ending update of Parties on the basis of ' || p_entity || ''''|| ');');
Line: 1999

l('--------DELETE ON THRESHOLD AND REMOVE INDIRECT TRANSITIVITY ---------------------');
Line: 2002

l('FND_FILE.put_line(FND_FILE.log,''DELETE ON THRESHOLD AND INDIRECT TRANSITIVITY '');');
Line: 2003

l('FND_FILE.put_line(FND_FILE.log,''Begin time to delete ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 2005

l('delete from hz_imp_dup_parties a');
Line: 2011

l('-- delete the party id whose duplicate is a bigger number, when scores are same');
Line: 2013

l('      (Select 1 from hz_imp_dup_parties b');
Line: 2016

l('-- delete the party id with least score, if scores are different');
Line: 2018

l('      (Select 1 from hz_imp_dup_parties b');
Line: 2022

l('FND_FILE.put_line(FND_FILE.log,''Number of records deleted from hz_imp_dup_parties ''||SQL%ROWCOUNT);');
Line: 2023

l('FND_FILE.put_line(FND_FILE.log,''End time to delete ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 2025

l('--------UPDATE AUTO MERGE FLAG --------------');
Line: 2026

l('update hz_imp_dup_parties a');
Line: 2031

l('--------UPDATE DQM ACTION FLAG IN INTERFACE/STAGING TABLES --------------');
Line: 2034

l('select a.party_osr, a.party_os, a.auto_merge_flag');
Line: 2038

l('HZ_DQM_DUP_ID_PKG.update_party_dqm_action_flag(p_batch_id, x_ent_cur);');
Line: 2057

                 select entity_name, search_table_name, entity_table_name, entity_id_name, entity_osr_name,
                        entity_os_name, sc, att_flag
                 from
                                    ( select  entity_name, decode(entity_name,
                                                   'PARTY','HZ_SRCH_PARTIES',
                                                   'PARTY_SITES', 'HZ_SRCH_PSITES',
                                                   'CONTACTS','HZ_SRCH_CONTACTS',
                                                   'CONTACT_POINTS', 'HZ_SRCH_CPTS') search_table_name,
                                                    decode(entity_name,
                                                   'PARTY','HZ_STAGED_PARTIES',
                                                   'PARTY_SITES', 'HZ_STAGED_PARTY_SITES',
                                                   'CONTACTS','HZ_STAGED_CONTACTS',
                                                   'CONTACT_POINTS', 'HZ_STAGED_CONTACT_POINTS') entity_table_name,
                                                    decode(entity_name,
                                                   'PARTY','PARTY_ID',
                                                   'PARTY_SITES', 'PARTY_SITE_ID',
                                                   'CONTACTS','ORG_CONTACT_ID',
                                                   'CONTACT_POINTS', 'CONTACT_POINT_ID') entity_id_name,
                                                   decode(entity_name,
                                                   'PARTY','PARTY_OSR',
                                                   'PARTY_SITES', 'PARTY_SITE_OSR',
                                                   'CONTACTS','CONTACT_OSR',
                                                   'CONTACT_POINTS', 'CONTACT_PT_OSR') entity_osr_name,
                                                   decode(entity_name,
                                                   'PARTY','PARTY_OS',
                                                   'PARTY_SITES', 'PARTY_SITE_OS',
                                                   'CONTACTS','CONTACT_OS',
                                                   'CONTACT_POINTS', 'CONTACT_PT_OS') entity_os_name,
                                                   sum(score) sc, 'S' att_flag
                                    from hz_trans_attributes_vl a, hz_match_rule_secondary s
                                    where s.match_rule_id = p_match_rule_id
                                    and s.attribute_id = a.attribute_id
                                    group by entity_name
                                    union all
                                              select  entity_name, decode(entity_name,
                                             'PARTY','HZ_SRCH_PARTIES',
                                             'PARTY_SITES', 'HZ_SRCH_PSITES',
                                             'CONTACTS','HZ_SRCH_CONTACTS',
                                             'CONTACT_POINTS', 'HZ_SRCH_CPTS') search_table_name,
                                              decode(entity_name,
                                             'PARTY','HZ_STAGED_PARTIES',
                                             'PARTY_SITES', 'HZ_STAGED_PARTY_SITES',
                                             'CONTACTS','HZ_STAGED_CONTACTS',
                                             'CONTACT_POINTS', 'HZ_STAGED_CONTACT_POINTS') entity_table_name,
                                              decode(entity_name,
                                             'PARTY','PARTY_ID',
                                             'PARTY_SITES', 'PARTY_SITE_ID',
                                             'CONTACTS','ORG_CONTACT_ID',
                                             'CONTACT_POINTS', 'CONTACT_POINT_ID') entity_id_name,
                                             decode(entity_name,
                                             'PARTY','PARTY_OSR',
                                             'PARTY_SITES', 'PARTY_SITE_OSR',
                                             'CONTACTS','CONTACT_OSR',
                                             'CONTACT_POINTS', 'CONTACT_PT_OSR') entity_osr_name,
                                             decode(entity_name,
                                             'PARTY','PARTY_OS',
                                             'PARTY_SITES', 'PARTY_SITE_OS',
                                             'CONTACTS','CONTACT_OS',
                                             'CONTACT_POINTS', 'CONTACT_PT_OS') entity_os_name,
                                             0 sc, 'P' att_flag
                                  from hz_trans_attributes_vl a, hz_match_rule_primary p
                                  where p.match_rule_id = p_match_rule_id
                                  and p.attribute_id = a.attribute_id
                                  group by entity_name
                             ) where att_flag = p_att_flag
                                order by sc desc ;
Line: 2129

insert_stmt_is_open boolean;
Line: 2133

    select match_score, match_all_flag into threshold, match_all_flag
    from hz_match_rules_vl
    where match_rule_id = p_match_rule_id;
Line: 2184

    insert_stmt_is_open := false;
Line: 2207

                    gen_insert_template_int_tca(entity_cur_rec.search_table_name,entity_cur_rec.entity_table_name, p_match_rule_id,
                                                                         entity_cur_rec.entity_name, match_all_flag);
Line: 2209

                    insert_stmt_is_open := true;
Line: 2223

                    gen_insert_template_int_tca(entity_cur_rec.search_table_name,entity_cur_rec.entity_table_name, p_match_rule_id,
                                                                             entity_cur_rec.entity_name, match_all_flag);
Line: 2226

                    IF insert_stmt_is_open
                    THEN
                        gen_insert_footer_int_tca(p_match_rule_id) ;
Line: 2229

                        insert_stmt_is_open := false;
Line: 2231

                    gen_update_template_int_tca(entity_cur_rec.search_table_name,entity_cur_rec.entity_table_name, p_match_rule_id,
                                                                     entity_cur_rec.entity_name, match_all_flag);
Line: 2243

                            gen_insert_template_int_tca(entity_cur_rec.search_table_name,entity_cur_rec.entity_table_name,
                                                        p_match_rule_id, entity_cur_rec.entity_name, match_all_flag);
Line: 2246

                            IF insert_stmt_is_open
                            THEN
                                gen_insert_footer_int_tca(p_match_rule_id) ;
Line: 2249

                                insert_stmt_is_open := false;
Line: 2251

                            gen_update_template_int_tca(entity_cur_rec.search_table_name,entity_cur_rec.entity_table_name, p_match_rule_id,
                                                           entity_cur_rec.entity_name, match_all_flag);
Line: 2259

                            gen_insert_template_int_tca(entity_cur_rec.search_table_name,entity_cur_rec.entity_table_name, p_match_rule_id,
                                                              entity_cur_rec.entity_name, match_all_flag);
Line: 2262

                            IF insert_stmt_is_open
                            THEN
                                gen_insert_footer_int_tca(p_match_rule_id) ;
Line: 2265

                                insert_stmt_is_open := false;
Line: 2267

                            gen_update_template_int_tca(entity_cur_rec.search_table_name,entity_cur_rec.entity_table_name,
                                                    p_match_rule_id, entity_cur_rec.entity_name, match_all_flag);
Line: 2278

                    gen_insert_template_int_tca(entity_cur_rec.search_table_name,entity_cur_rec.entity_table_name,
                                              p_match_rule_id, entity_cur_rec.entity_name, match_all_flag);
Line: 2281

                    IF insert_stmt_is_open
                    THEN
                        gen_insert_footer_int_tca(p_match_rule_id);
Line: 2284

                        insert_stmt_is_open := false;
Line: 2286

                    gen_update_template_int_tca(entity_cur_rec.search_table_name, entity_cur_rec.entity_table_name,
                                            p_match_rule_id, entity_cur_rec.entity_name, match_all_flag);
Line: 2295

        IF insert_stmt_is_open
        THEN
            gen_insert_footer_int_tca(p_match_rule_id) ;
Line: 2298

            insert_stmt_is_open := false;
Line: 2309

                gen_dl_insert_template_int_tca(entity_cur_rec.search_table_name,
                                               entity_cur_rec.entity_table_name,
                                               p_match_rule_id,
                                               entity_cur_rec.entity_name,
                                               entity_cur_rec.entity_id_name,
                                               entity_cur_rec.entity_osr_name,
                                               entity_cur_rec.entity_os_name,
                                               match_all_flag );
Line: 2367

    temp := get_insert_threshold(p_match_rule_id);
Line: 2368

    l('    x_insert_threshold number := ' || temp || ';');
Line: 2372

    l('FND_FILE.put_line(FND_FILE.log,''Start time of insert of Parties ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 2373

    l('insert into hz_int_dup_results(batch_id, f_osr,t_osr,ord_f_osr,ord_t_osr,score,f_os, t_os)');
Line: 2374

    l('select p_batch_id, f, t, least(f,t), greatest(f,t), sum(score) score, fos, tos from (');
Line: 2380

PROCEDURE gen_insert_template_int(
       s_table VARCHAR2,
       p_table VARCHAR2,
       p_match_rule_id NUMBER,
       p_entity VARCHAR2,
       p_match_all_flag VARCHAR2
)
IS
FIRST BOOLEAN ;
Line: 2398

        l('select f, t, max(score) score, fos, tos from (');
Line: 2401

     l('select /*+ USE_CONCAT */ s1.party_osr f, s2.party_osr t,');
Line: 2406

   SELECT count(1) into outer_row_count
   FROM HZ_MATCH_RULE_SECONDARY s, HZ_TRANS_ATTRIBUTES_VL a
   where a.attribute_id=s.attribute_id
   and s.match_rule_id=p_match_rule_id
   and a.entity_name = p_entity;
Line: 2416

          SELECT score,s.attribute_id , secondary_attribute_id
          FROM HZ_MATCH_RULE_SECONDARY s, HZ_TRANS_ATTRIBUTES_VL a
          where a.attribute_id=s.attribute_id
          and s.match_rule_id=p_match_rule_id
          and a.entity_name = p_entity)
          LOOP
              outer_row_counter := outer_row_counter + 1;
Line: 2426

                      SELECT round(transformation_weight/100*attrs.score) score, staged_attribute_column
                      FROM hz_secondary_trans st, hz_trans_functions_vl f
                      where f.function_id=st.function_id
                      and st.secondary_attribute_id = attrs.secondary_attribute_id
                      order by transformation_weight desc)
                    LOOP
                                inner_row_counter := inner_row_counter + 1;
Line: 2469

   l('and s2.batch_id = p_batch_id and not exists (select 1 from HZ_INT_DUP_RESULTS WHERE t_osr = s1.party_osr and batch_id = p_batch_id)');
Line: 2483

    SELECT primary_attribute_id
    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
    where  p.match_rule_id=p_match_rule_id
    and p.attribute_id=a.attribute_id
    and a.entity_name = p_entity
    and nvl(p.filter_flag,'N') = 'N' )
   LOOP
                -- between attributes
                IF FIRST1
                THEN
                   FIRST1 := FALSE;
Line: 2506

               FOR trans in ( SELECT staged_attribute_column
                  FROM hz_primary_trans pt, hz_trans_functions_vl f
                  where f.function_id = pt.function_id
                  and pt.primary_attribute_id = attrs.primary_attribute_id
               )
               LOOP
                    IF FIRST
                    THEN
                        l('-- do an or between all the transformations of an attribute -- ');
Line: 2539

                        SELECT primary_attribute_id
                        FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
                        where  p.match_rule_id=p_match_rule_id
                        and p.attribute_id=a.attribute_id
                        and a.entity_name = p_entity
                        and nvl(p.filter_flag,'N') = 'Y' )
                       LOOP
                                    -- between attributes
                                    IF FIRST1
                                    THEN
                                       FIRST1 := FALSE;
Line: 2557

                                   FOR trans in ( SELECT staged_attribute_column
                                      FROM hz_primary_trans pt, hz_trans_functions_vl f
                                      where f.function_id = pt.function_id
                                      and pt.primary_attribute_id = attrs.primary_attribute_id
                                   )
                                   LOOP
                                        IF FIRST
                                        THEN
                                            l('-- do an or between all the transformations of an attribute -- ');
Line: 2597

PROCEDURE gen_dl_insert_template_int(
       s_table VARCHAR2,
       p_table VARCHAR2,
       p_match_rule_id NUMBER,
       p_entity VARCHAR2,
       p_entity_osr_name VARCHAR2,
       p_entity_os_name VARCHAR2,
       p_match_all_flag VARCHAR2
)
IS
FIRST BOOLEAN ;
Line: 2617

   l('FND_FILE.put_line(FND_FILE.log,'||''''|| 'Beginning insert  of ' || p_entity || ''''|| ');');
Line: 2618

   l('FND_FILE.put_line(FND_FILE.log,''Start time of insert ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 2619

   l('insert into hz_imp_int_dedup_results(batch_id, winner_record_osr, winner_record_os,');
Line: 2621

   l('dup_creation_date,dup_last_update_date');
Line: 2622

   l(',created_by,creation_date,last_update_login,last_update_date,last_updated_by)');
Line: 2623

   l('select /*+ USE_CONCAT */ p_batch_id, s1.' || p_entity_osr_name || ', s1.' || p_entity_os_name || ',');
Line: 2626

   SELECT count(1) into outer_row_count
   FROM HZ_MATCH_RULE_SECONDARY s, HZ_TRANS_ATTRIBUTES_VL a
   where a.attribute_id=s.attribute_id
   and s.match_rule_id=p_match_rule_id
   and a.entity_name = p_entity;
Line: 2636

            SELECT score,s.attribute_id , secondary_attribute_id
            FROM HZ_MATCH_RULE_SECONDARY s, HZ_TRANS_ATTRIBUTES_VL a
            where a.attribute_id=s.attribute_id
            and s.match_rule_id=p_match_rule_id
            and a.entity_name = p_entity)
            LOOP
                outer_row_counter := outer_row_counter + 1;
Line: 2646

                        SELECT round(transformation_weight/100*attrs.score) score, staged_attribute_column
                        FROM hz_secondary_trans st, hz_trans_functions_vl f
                        where f.function_id=st.function_id
                        and st.secondary_attribute_id = attrs.secondary_attribute_id
                        order by transformation_weight desc)
                      LOOP
                                  inner_row_counter := inner_row_counter + 1;
Line: 2676

   l('score ,hz_utility_v2pub.creation_date, hz_utility_v2pub.last_update_date');
Line: 2677

   l(',hz_utility_v2pub.created_by,hz_utility_v2pub.creation_date,hz_utility_v2pub.last_update_login');
Line: 2678

   l(',hz_utility_v2pub.last_update_date,hz_utility_v2pub.last_updated_by');
Line: 2697

    SELECT primary_attribute_id
    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
    where  p.match_rule_id=p_match_rule_id
    and p.attribute_id=a.attribute_id
    and a.entity_name = p_entity
    and nvl(p.filter_flag,'N') = 'N' )
   LOOP
                -- between attributes
                IF FIRST1
                THEN
                   FIRST1 := FALSE;
Line: 2720

               FOR trans in ( SELECT staged_attribute_column
                  FROM hz_primary_trans pt, hz_trans_functions_vl f
                  where f.function_id = pt.function_id
                  and pt.primary_attribute_id = attrs.primary_attribute_id
               )
               LOOP
                    IF FIRST
                    THEN
                        l('-- do an or between all the transformations of an attribute -- ');
Line: 2749

    SELECT primary_attribute_id
    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
    where  p.match_rule_id=p_match_rule_id
    and p.attribute_id=a.attribute_id
    and a.entity_name = p_entity
    and nvl(p.filter_flag,'N') = 'Y'
    and HZ_IMP_DQM_STAGE.EXIST_COL(a.attribute_name, a.entity_name ) = 'Y'
    )
   LOOP
                -- between attributes
                IF FIRST1
                THEN
                   FIRST1 := FALSE;
Line: 2768

               FOR trans in ( SELECT staged_attribute_column
                  FROM hz_primary_trans pt, hz_trans_functions_vl f
                  where f.function_id = pt.function_id
                  and pt.primary_attribute_id = attrs.primary_attribute_id
               )
               LOOP
                    IF FIRST
                    THEN
                        l('-- do an or between all the transformations of an attribute -- ');
Line: 2799

l('FND_FILE.put_line(FND_FILE.log,'||''''|| 'Ending insert of ' || p_entity || ''''|| ');');
Line: 2800

l('FND_FILE.put_line(FND_FILE.log,''Number of records inserted ''||SQL%ROWCOUNT);');
Line: 2801

l('FND_FILE.put_line(FND_FILE.log,''End time to insert ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 2808

PROCEDURE gen_insert_footer_int(p_match_rule_id number)
IS
FIRST1 boolean;
Line: 2820

                   l('SELECT 1 FROM HZ_SRCH_PARTIES p1, HZ_SRCH_PARTIES p2');
Line: 2825

                    SELECT primary_attribute_id
                    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
                    where  p.match_rule_id=p_match_rule_id
                    and p.attribute_id=a.attribute_id
                    and a.entity_name = 'PARTY'
                    and nvl(p.filter_flag,'N') = 'Y'
                    and HZ_IMP_DQM_STAGE.EXIST_COL(a.attribute_name, a.entity_name ) = 'Y'
                    )
                   LOOP
                              IF FIRST1
                              THEN
                                   FIRST1 := FALSE;
Line: 2843

                               FOR trans in ( SELECT staged_attribute_column
                                  FROM hz_primary_trans pt, hz_trans_functions_vl f
                                  where f.function_id = pt.function_id
                                  and pt.primary_attribute_id = attrs.primary_attribute_id
                               )
                               LOOP
                                     IF FIRST
                                     THEN
                                        l('-- do an or between all the transformations of an attribute -- ');
Line: 2875

    IF get_insert_threshold(p_match_rule_id) > 0
    THEN
        l('having sum(score) >= x_insert_threshold');
Line: 2881

   l('FND_FILE.put_line(FND_FILE.log,''Number of parties inserted ''||SQL%ROWCOUNT);');
Line: 2882

   l('FND_FILE.put_line(FND_FILE.log,''End time of insert ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 2890

PROCEDURE gen_update_template_int (
        s_table VARCHAR2,
        p_table VARCHAR2,
        p_match_rule_id NUMBER,
        p_entity VARCHAR2,
        p_match_all_flag VARCHAR2
)
IS
FIRST BOOLEAN ;
Line: 2909

   l('FND_FILE.put_line(FND_FILE.log,'||''''|| 'Beginning update of Parties on the basis of ' || p_entity || ''''|| ');');
Line: 2910

   l('FND_FILE.put_line(FND_FILE.log,''Start time of update ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 2912

   l('select f,t,max(score) from (');
Line: 2913

   l(' select /*+ USE_CONCAT */ s1.party_osr f, s2.party_osr t,');
Line: 2916

    SELECT count(1) into outer_row_count
   FROM HZ_MATCH_RULE_SECONDARY s, HZ_TRANS_ATTRIBUTES_VL a
   where a.attribute_id=s.attribute_id
   and s.match_rule_id=p_match_rule_id
   and a.entity_name = p_entity;
Line: 2926

            SELECT score,s.attribute_id , secondary_attribute_id
            FROM HZ_MATCH_RULE_SECONDARY s, HZ_TRANS_ATTRIBUTES_VL a
            where a.attribute_id=s.attribute_id
            and s.match_rule_id=p_match_rule_id
            and a.entity_name = p_entity)
            LOOP
                outer_row_counter := outer_row_counter + 1;
Line: 2936

                        SELECT round(transformation_weight/100*attrs.score) score, staged_attribute_column
                        FROM hz_secondary_trans st, hz_trans_functions_vl f
                        where f.function_id=st.function_id
                        and st.secondary_attribute_id = attrs.secondary_attribute_id
                        order by transformation_weight desc)
                      LOOP
                                  inner_row_counter := inner_row_counter + 1;
Line: 2986

    SELECT primary_attribute_id
    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
    where  p.match_rule_id=p_match_rule_id
    and p.attribute_id=a.attribute_id
    and a.entity_name = p_entity
    and nvl(p.filter_flag,'N') = 'N' )
   LOOP
                -- between attributes
                IF FIRST1
                THEN
                   FIRST1 := FALSE;
Line: 3009

               FOR trans in ( SELECT staged_attribute_column
                  FROM hz_primary_trans pt, hz_trans_functions_vl f
                  where f.function_id = pt.function_id
                  and pt.primary_attribute_id = attrs.primary_attribute_id
               )
               LOOP
                    IF FIRST
                    THEN
                        l('-- do an or between all the transformations of an attribute -- ');
Line: 3038

    SELECT primary_attribute_id
    FROM HZ_MATCH_RULE_PRIMARY p, HZ_TRANS_ATTRIBUTES_VL a
    where  p.match_rule_id=p_match_rule_id
    and p.attribute_id=a.attribute_id
    and a.entity_name = p_entity
    and nvl(p.filter_flag,'N') = 'Y' )
   LOOP
                -- between attributes
                IF FIRST1
                THEN
                   FIRST1 := FALSE;
Line: 3055

               FOR trans in ( SELECT staged_attribute_column
                  FROM hz_primary_trans pt, hz_trans_functions_vl f
                  where f.function_id = pt.function_id
                  and pt.primary_attribute_id = attrs.primary_attribute_id
               )
               LOOP
                    IF FIRST
                    THEN
                        l('-- do an or between all the transformations of an attribute -- ');
Line: 3081

   l('HZ_DQM_DUP_ID_PKG.update_hz_int_dup_results(p_batch_id,x_ent_cur);');
Line: 3083

   l('FND_FILE.put_line(FND_FILE.log,''Number of parties updated ''||SQL%ROWCOUNT);');
Line: 3084

   l('FND_FILE.put_line(FND_FILE.log,''End time to update ''||to_char(sysdate,''hh24:mi:ss''));');
Line: 3085

   l('FND_FILE.put_line(FND_FILE.log,'||''''|| 'Ending update of Parties on the basis of ' || p_entity || ''''|| ');');
Line: 3122

                select entity_name, search_table_name, entity_table_name, entity_osr_name, entity_os_name, sc, att_flag
                from
                        (select  entity_name, decode(entity_name,
                                       'PARTY','HZ_SRCH_PARTIES',
                                       'PARTY_SITES', 'HZ_SRCH_PSITES',
                                       'CONTACTS','HZ_SRCH_CONTACTS',
                                       'CONTACT_POINTS', 'HZ_SRCH_CPTS') search_table_name,
                                        decode(entity_name,
                                       'PARTY','HZ_STAGED_PARTIES',
                                       'PARTY_SITES', 'HZ_STAGED_PARTY_SITES',
                                       'CONTACTS','HZ_STAGED_CONTACTS',
                                       'CONTACT_POINTS', 'HZ_STAGED_CONTACT_POINTS') entity_table_name,
                                        decode(entity_name,
                                       'PARTY','PARTY_OSR',
                                       'PARTY_SITES', 'PARTY_SITE_OSR',
                                       'CONTACTS','CONTACT_OSR',
                                       'CONTACT_POINTS', 'CONTACT_PT_OSR') entity_osr_name,
                                        decode(entity_name,
                                       'PARTY','PARTY_OS',
                                       'PARTY_SITES', 'PARTY_SITE_OS',
                                       'CONTACTS','CONTACT_OS',
                                       'CONTACT_POINTS', 'CONTACT_PT_OS') entity_os_name,
                                       sum(score) sc, 'S' att_flag
                        from hz_trans_attributes_vl a, hz_match_rule_secondary s
                        where s.match_rule_id = p_match_rule_id
                        and s.attribute_id = a.attribute_id
                        group by entity_name
                        union all
                      select  entity_name, decode(entity_name,
                     'PARTY','HZ_SRCH_PARTIES',
                     'PARTY_SITES', 'HZ_SRCH_PSITES',
                     'CONTACTS','HZ_SRCH_CONTACTS',
                     'CONTACT_POINTS', 'HZ_SRCH_CPTS') search_table_name,
                      decode(entity_name,
                     'PARTY','HZ_STAGED_PARTIES',
                     'PARTY_SITES', 'HZ_STAGED_PARTY_SITES',
                     'CONTACTS','HZ_STAGED_CONTACTS',
                     'CONTACT_POINTS', 'HZ_STAGED_CONTACT_POINTS') entity_table_name,
                      decode(entity_name,
                     'PARTY','PARTY_OSR',
                     'PARTY_SITES', 'PARTY_SITE_OSR',
                     'CONTACTS','CONTACT_OSR',
                     'CONTACT_POINTS', 'CONTACT_PT_OSR') entity_osr_name,
                      decode(entity_name,
                     'PARTY','PARTY_OS',
                     'PARTY_SITES', 'PARTY_SITE_OS',
                     'CONTACTS','CONTACT_OS',
                     'CONTACT_POINTS', 'CONTACT_PT_OS') entity_os_name,
                      0 sc, 'P' att_flag
                      from hz_trans_attributes_vl a, hz_match_rule_primary p
                      where p.match_rule_id = p_match_rule_id
                      and  p.attribute_id = a.attribute_id
                      group by entity_name
                ) where att_flag = p_att_flag
                order by sc desc ;
Line: 3183

insert_stmt_is_open boolean;
Line: 3187

    select match_score, match_all_flag into threshold, match_all_flag
    from hz_match_rules_vl
    where match_rule_id = p_match_rule_id;
Line: 3238

    insert_stmt_is_open := false;
Line: 3261

                    gen_insert_template_int(entity_cur_rec.search_table_name,entity_cur_rec.entity_table_name, p_match_rule_id,
                                                                         entity_cur_rec.entity_name, match_all_flag);
Line: 3263

                    insert_stmt_is_open := true;
Line: 3277

                    gen_insert_template_int(entity_cur_rec.search_table_name,entity_cur_rec.entity_table_name, p_match_rule_id,
                                                                             entity_cur_rec.entity_name, match_all_flag);
Line: 3280

                    IF insert_stmt_is_open
                    THEN
                        gen_insert_footer_int(p_match_rule_id) ;
Line: 3283

                        insert_stmt_is_open := false;
Line: 3285

                    gen_update_template_int(entity_cur_rec.search_table_name,entity_cur_rec.entity_table_name, p_match_rule_id,
                                                                     entity_cur_rec.entity_name, match_all_flag);
Line: 3297

                            gen_insert_template_int(entity_cur_rec.search_table_name,entity_cur_rec.entity_table_name,
                                                        p_match_rule_id, entity_cur_rec.entity_name, match_all_flag);
Line: 3300

                            IF insert_stmt_is_open
                            THEN
                                gen_insert_footer_int(p_match_rule_id) ;
Line: 3303

                                insert_stmt_is_open := false;
Line: 3305

                            gen_update_template_int(entity_cur_rec.search_table_name,entity_cur_rec.entity_table_name, p_match_rule_id,
                                                           entity_cur_rec.entity_name, match_all_flag);
Line: 3313

                            gen_insert_template_int(entity_cur_rec.search_table_name,entity_cur_rec.entity_table_name, p_match_rule_id,
                                                              entity_cur_rec.entity_name, match_all_flag);
Line: 3316

                            IF insert_stmt_is_open
                            THEN
                                gen_insert_footer_int(p_match_rule_id) ;
Line: 3319

                                insert_stmt_is_open := false;
Line: 3321

                            gen_update_template_int(entity_cur_rec.search_table_name,entity_cur_rec.entity_table_name,
                                                    p_match_rule_id, entity_cur_rec.entity_name, match_all_flag);
Line: 3332

                    gen_insert_template_int(entity_cur_rec.search_table_name,entity_cur_rec.entity_table_name,
                                              p_match_rule_id, entity_cur_rec.entity_name, match_all_flag);
Line: 3335

                    IF insert_stmt_is_open
                    THEN
                        gen_insert_footer_int(p_match_rule_id);
Line: 3338

                        insert_stmt_is_open := false;
Line: 3340

                    gen_update_template_int(entity_cur_rec.search_table_name, entity_cur_rec.entity_table_name,
                                            p_match_rule_id, entity_cur_rec.entity_name, match_all_flag);
Line: 3349

        IF insert_stmt_is_open
        THEN
            gen_insert_footer_int(p_match_rule_id) ;
Line: 3352

            insert_stmt_is_open := false;
Line: 3360

                gen_dl_insert_template_int(entity_cur_rec.search_table_name,entity_cur_rec.entity_table_name,
                                          p_match_rule_id, entity_cur_rec.entity_name, entity_cur_rec.entity_osr_name,
                                                           entity_cur_rec.entity_os_name, match_all_flag );