DBA Data[Home] [Help]

APPS.HZ_MIXNM_DYNAMIC_PKG_GENERATOR SQL Statements

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

Line: 130

PROCEDURE getBulkUpdateWhereCondition
IS
BEGIN

    li('  WHERE sst.'||'party_id BETWEEN p_from_party_id AND p_to_party_id');
Line: 139

END getBulkUpdateWhereCondition;
Line: 142

PROCEDURE getImportUpdateWhereCondition
IS
BEGIN

    li('  WHERE sst.'||'party_id = sg.party_id ');
Line: 155

END getImportUpdateWhereCondition;
Line: 300

   select aa.argument_name, aa.data_type, aa.data_length, party.column_name
     from sys.all_arguments aa, (
          select min(a.sequence) id
            from sys.all_arguments a
           where a.object_name = 'GET_' ||upper (p_entity_name)||'_REC'
             and a.type_subname = upper (p_entity_name) || '_REC_TYPE'
             and a.data_level = 0
             and a.object_id in (
                 select b.object_id
                   from sys.all_objects b
                  where b.object_name = 'HZ_PARTY_V2PUB'
                    and b.owner = l_apps_schema
                    and b.object_type = 'PACKAGE')) temp1, (
          select column_name
            from sys.all_tab_columns c
           where c.table_name = 'HZ_PARTIES'
             and c.owner = l_ar_schema
             and exists (
                 select null
                   from sys.all_tab_columns c2
                  where c2.owner = l_ar_schema
                    and c2.column_name = c.column_name
                    and c2.table_name = 'HZ_' ||upper (p_entity_name) || '_PROFILES')
             and c.column_name not like 'ATTRIBUTE%'
             and c.column_name not like 'GLOBAL_ATTRIBUTE%'
             and c.column_name not in ('APPLICATION_ID')) party
    where aa.object_name = 'GET_' ||upper (p_entity_name)||'_REC'
      and aa.data_level = 1
      and aa.data_type <> 'PL/SQL RECORD'
      and aa.argument_name not in ('CONTENT_SOURCE_TYPE',
          'ACTUAL_CONTENT_SOURCE', 'APPLICATION_ID')
      and aa.sequence > temp1.id
      and aa.object_id in (
          select b.object_id
            from sys.all_objects b
           where b.object_name = 'HZ_PARTY_V2PUB'
             and b.owner = l_apps_schema
             and b.object_type = 'PACKAGE')
      and aa.argument_name = party.column_name (+)
    union all
   select 'BANK_CODE' argument_name, 'VARCHAR2' data_type,
          30 data_length, null column_name
     from dual
    union all
   select 'BANK_OR_BRANCH_NUMBER' argument_name, 'VARCHAR2' data_type,
          60 data_length, null column_name
     from dual
    union all
   select 'BRANCH_CODE' argument_name, 'VARCHAR2' data_type,
          30 data_length, null column_name
     from dual
    order by argument_name;
Line: 356

      SELECT attribute_group_name, attribute_name, entity_attr_id
      FROM hz_entity_attributes
      WHERE attribute_name IS NOT NULL
      ORDER BY attribute_group_name;
Line: 660

      li(p_prefix||'  write_log(SQL%ROWCOUNT||'' records have been created / updated.'');');
Line: 691

    p_insert_update_flag            IN     VARCHAR2,
    p_option                        IN     VARCHAR2,
    p_prefix                        IN     VARCHAR2,
    p_extended_who_flag             IN     VARCHAR2
) IS
BEGIN

    IF p_insert_update_flag = 'I' THEN
      IF p_option = 'LIST' THEN

        l(p_prefix||'created_by,');
Line: 703

        l(p_prefix||'last_update_login,');
Line: 704

        l(p_prefix||'last_update_date,');
Line: 705

        ll(p_prefix||'last_updated_by');
Line: 712

          ll(p_prefix||'program_update_date');
Line: 719

        l(p_prefix||'g_last_update_login,');
Line: 721

        ll(p_prefix||'g_last_updated_by');
Line: 733

    ELSE -- IF p_insert_update_flag = 'I' THEN

      l(p_prefix||'last_updated_by = g_last_updated_by,');
Line: 736

      l(p_prefix||'last_update_login = g_last_update_login,');
Line: 737

      ll(p_prefix||'last_update_date = SYSDATE');
Line: 744

        ll(p_prefix||'program_update_date = SYSDATE');
Line: 949

 *   				        update_exception_table_date. This
 *   				        procedure is to populate exception
 *   				        table for 'By Date' attributes.
 */

PROCEDURE Gen_CommonProceduresForConc IS

    l_procedure_name          VARCHAR2(30);
Line: 968

    l(fp('g_last_update_login')||'NUMBER;');
Line: 969

    l(fp('g_last_updated_by')||'NUMBER;');
Line: 1022

    li('g_last_update_login := hz_utility_v2pub.last_update_login;');
Line: 1023

    li('g_last_updated_by := hz_utility_v2pub.last_updated_by;');
Line: 1031

     + update_rel_party_name
     +===============================================================*/

    l_procedure_name := 'update_rel_party_name';
Line: 1040

    li('  SELECT r.party_id, r.object_id, o.party_name, r.subject_id, s.party_name');
Line: 1064

    li('  UPDATE hz_parties');
Line: 1075

     + update_exception_table
     +===============================================================*/

    l_procedure_name := 'update_exception_table';
Line: 1081

    li(fp('p_create_update_flag')||'IN     VARCHAR2,');
Line: 1107

    li('IF p_create_update_flag = ''C'' THEN');
Line: 1109

    li('    INSERT INTO hz_win_source_exceps (');
Line: 1143

    li('    DELETE hz_win_source_exceps');
Line: 1148

    li('    write_log(''Deleted ''||sql%ROWCOUNT||'' exceptions.'');');
Line: 1152

    li('    UPDATE hz_win_source_exceps');
Line: 1162

    li('    write_log(''Updated ''||sql%ROWCOUNT||'' exceptions.'');');
Line: 1166

    li('    INSERT INTO hz_win_source_exceps (');
Line: 1174

    li('    SELECT');
Line: 1184

    li('      SELECT ''Y''');
Line: 1197

      + SSM SST Project : update_exception_table for Date Attributes
      +===============================================================*/

    l_procedure_name := 'update_exception_table_date';
Line: 1203

    li(fp('p_create_update_flag')||'IN     VARCHAR2,');
Line: 1214

    li('IF p_create_update_flag = ''C'' THEN');
Line: 1216

    li('    INSERT INTO hz_win_source_exceps (');
Line: 1239

    li('    UPDATE hz_win_source_exceps');
Line: 1248

    li('    INSERT INTO hz_win_source_exceps (');
Line: 1267

    li('    write_log(''Updated ''||sql%ROWCOUNT||'' exceptions.'');');
Line: 1335

    li('  write_log(''update party name of relationship parties.'');');
Line: 1338

    li('    update_rel_party_name(i_party_id(i));');
Line: 1365

PROCEDURE Gen_WriteOutputFileForUpdate IS
BEGIN

    li('  FOR i IN create_start..create_end LOOP');
Line: 1372

    li('  FOR i IN update_start..update_end LOOP');
Line: 1373

    li('    write_out(''updated : party id = ''||i_party_id(i)||'', sst profile id = ''||i_profile_id(i));');
Line: 1377

END Gen_WriteOutputFileForUpdate;
Line: 1387

 * 	Select the attribute and corresponding actual_content_source
 * 	from the last updated profile among the visible data
 * 	sources for this attribute.
 *
	CURSOR c_KNOWN_AS5 IS
	SELECT user_entered.known_as5, user_entered.actual_content_source
	FROM ( SELECT row_number() over
		(partition by ue.party_id order by ue.last_update_date desc nulls last) rank,
		ue.known_as5 , ue.actual_content_source
	    	FROM hz_organization_profiles ue
		WHERE ue.party_id BETWEEN p_from_party_id AND p_to_party_id
	    	AND ue.effective_end_date IS NULL
	    	AND ue.actual_content_source in ( 'DNB' ,'USER_ENTERED' ...)
	    AND NOT EXISTS (
		USER_ENTERED profile
	    AND EXISTS (
		NON SST, USER_ENTERED profile
	  ) user_entered
	WHERE user_entered.rank = 1

 * MODIFICATION HISTORY
 *
 *  17-12-2004	Dhaval Metha	SSM SST Project
 *  				~ Created.
 */
procedure date_cursor_create(attr_id IN NUMBER,
	attr_name IN VARCHAR2,
	p_entity_name IN VARCHAR2,
	p_purpose IN VARCHAR2) IS
cursor data_sources is
select content_source_type
from hz_select_data_sources
where entity_attr_id = attr_id
and ranking <> 0;
Line: 1435

    li('  SELECT ');
Line: 1444

      li('( SELECT ');
Line: 1446

      ll('	(partition by ue.party_id order by ue.last_update_date desc nulls last) rank, ');
Line: 1477

      li('    SELECT ''Y''');
Line: 1486

      li('    SELECT ''Y''');
Line: 1497

 * PRIVATE PROCEDURE date_cursor_update
 *
 * DESCRIPTION
 * 	This procedure is used to generate cursor for
 * 	passed attribute_id setup as 'By Date' for
 * 	BulkUpdateSST and ImportUpdateSST procedures.
 * 	Select the attribute and corresponding actual_content_source
 * 	from the last updated profile among the visible data
 * 	sources for this attribute.
 *
	CURSOR c_KNOWN_AS5 IS
	SELECT user_entered.known_as5, user_entered.actual_content_source
	FROM ( SELECT decode(fnd_profile.value ('HZ_PROFILE_VERSION'),'NEW_VERSION','C',
			'NO_VERSION','U',
			decode(trunc(ue.effective_start_date),trunc(sysdate),'U','C')) create_update_flag,
           	ue.organization_profile_id,
	        ue.party_id,row_number() over
		(partition by ue.party_id order by ue.last_update_date desc nulls last) rank,
		ue.known_as5 , ue.actual_content_source
	    	FROM hz_organization_profiles ue
		WHERE ue.party_id BETWEEN p_from_party_id AND p_to_party_id
	    	AND ue.effective_end_date IS NULL
	    	AND ue.actual_content_source in ( 'DNB' ,'USER_ENTERED' ...)
	    AND EXISTS (
		USER_ENTERED profile
	    AND EXISTS (
		SST profile
	  ) user_entered
	WHERE user_entered.rank = 1
	ORDER BY create_update_flag

 * MODIFICATION HISTORY
 *
 *  17-12-2004	Dhaval Metha	SSM SST Project
 *  				~ Created.
 */
procedure date_cursor_update(attr_id IN NUMBER,
	attr_name IN VARCHAR2,
	p_entity_name IN VARCHAR2,
	p_purpose IN VARCHAR2) IS
cursor data_sources is
select content_source_type
from hz_select_data_sources
where entity_attr_id = attr_id
and ranking <> 0;
Line: 1556

    li('  SELECT ');
Line: 1565

    li('  SELECT decode(fnd_profile.value (''HZ_PROFILE_VERSION''),''NEW_VERSION'',''C'',''NO_VERSION'',''U'',decode(trunc(sst.effective_start_date),trunc(sysdate),''U'',''C'')) create_update_flag, ');
Line: 1570

      ll('	(partition by ue.party_id order by ue.last_update_date desc nulls last) rank, ');
Line: 1607

    li('    SELECT ''Y''');
Line: 1614

    li('ORDER BY create_update_flag,user_entered.party_id;');
Line: 1615

END date_cursor_update;
Line: 1634

 *  				  and use them in same insert statement as
 *  				  'By Rank' attributes
 *  				~ populate the exception table for
 *  				  'By Date' attributes.
 */

PROCEDURE Gen_BulkCreateSST (
    p_entity_name                   IN     VARCHAR2,
    p_purpose                       IN     VARCHAR2
) IS

    CURSOR c_restricted_attributes IS
      SELECT e.attribute_name, e.entity_attr_id,
             e.group_flag, s.content_source_type
      FROM
        (SELECT e.attribute_name, e.entity_attr_id, 'N' group_flag
         FROM hz_entity_attributes e
         WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
         UNION
         SELECT e.attribute_group_name,
                MIN(entity_attr_id) entity_attr_id,
                'Y' group_flag
         FROM hz_entity_attributes e
         WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
         AND NOT EXISTS (
           SELECT 'Y'
           FROM hz_entity_attributes e1
           WHERE e.attribute_group_name = e1.attribute_name)
         GROUP BY e.attribute_group_name) e,
        hz_select_data_sources s
      WHERE EXISTS (
        SELECT 'Y'
        FROM hz_select_data_sources s1
        WHERE s1.entity_attr_id = e.entity_attr_id
        AND s1.content_source_type <> 'USER_ENTERED'
        AND s1.ranking > 0 )
      AND s.entity_attr_id = e.entity_attr_id
      AND s.ranking > 0
      ORDER BY e.attribute_name, s.ranking;
Line: 1686

      SELECT UNIQUE s.content_source_type
      FROM hz_entity_attributes e,
           hz_select_data_sources s
      WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
      AND e.entity_attr_id = s.entity_attr_id
      AND s.ranking > 0;
Line: 1696

      SELECT e.attribute_group_name, e.attribute_name
      FROM hz_entity_attributes e,
        (SELECT UNIQUE attribute_group_name
         FROM hz_entity_attributes
         WHERE entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
         GROUP BY attribute_group_name
         HAVING COUNT(*) > 1) e1
      WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
      AND e.attribute_group_name = e1.attribute_group_name
      AND e.attribute_group_name <> e.attribute_name
      AND EXISTS (
        SELECT 'Y'
        FROM hz_select_data_sources s1
        WHERE s1.entity_attr_id = e.entity_attr_id
        AND s1.content_source_type <> 'USER_ENTERED'
        AND s1.ranking > 0 );
Line: 1743

         SELECT distinct e.attribute_name, e.entity_attr_id
         FROM hz_entity_attributes e,
         hz_select_data_sources s
         WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
         AND EXISTS (
         SELECT 'Y'
         FROM hz_select_data_sources s1
         WHERE s1.entity_attr_id = e.entity_attr_id
         AND s1.ranking < 0 )
         AND s.entity_attr_id = e.entity_attr_id
         AND s.ranking < 0
         ORDER BY e.attribute_name;
Line: 1838

     + select for restricted columns (i.e. columns have been selected)
     +
     +   SELECT ...
     +          --
     +          -- processing branch_flag.
     +          DECODE(dnb.branch_flag, NULL,
     +            DECODE(user_entered.branch_flag, NULL,
     +            NULL,
     +            user_entered.branch_flag||'%#USER_ENTERED'),
     +          dnb.branch_flag||'%#DNB') branch_flag,
     +          --
     +          -- processing ceo_name.
     +          DECODE(user_entered.ceo_name, NULL,
     +            DECODE(dnb.ceo_name, NULL,
     +            NULL,
     +            dnb.ceo_name||'%#DNB'),
     +          user_entered.ceo_name||'%#USER_ENTERED') ceo_name,
     +          --
     +          ...
     +===============================================================*/

    l_cursor_name := 'c_entity';
Line: 1863

    li('  SELECT d_user_entered.'||p_entity_name||'_profile_id,');
Line: 1937

     + select normal columns (i.e. columns not in setup tables and
     + columns not selected)
     +
     +          --
     +          -- processing attribute1.
     +          user_entered.attribute1,
     +          --
     +          -- processing attribute2.
     +          user_entered.attribute2,
     +          ...
     +===============================================================*/

    FOR i IN 1..i_normal_attributes.COUNT LOOP
      l(',');
Line: 2028

    li('    SELECT ''Y''');
Line: 2037

    li('    SELECT ''Y''');
Line: 2192

    li('    UPDATE hz_'||p_entity_name||'_profiles ');
Line: 2201

     + select attributes inside an attribute group
     +===============================================================*/

    OPEN c_groups;
Line: 2268

        li('      SELECT');
Line: 2285

    li('  -- insert sst profiles');
Line: 2288

    li('    INSERT INTO hz_'||p_entity_name||'_profiles (');
Line: 2300

     + column list of insert statement
     +
     +   duns_number_c,
     +   employees_total,
     +   ...
     +===============================================================*/

    FOR i IN 1..i_uq_attribute_name.COUNT LOOP
      l(',');
Line: 2332

     + value list of insert statement
     +
     +   SUBSTRB(i_duns_number_c(i),1,INSTRB(i_duns_number_c(i),'%#')-1),
     +   TO_NUMBER(SUBSTRB(i_employees_total(i),1, INSTRB(i_employees_total(i),'%#')-1)),
     +   ...
     +===============================================================*/

    Gen_CodeForWhoColumns('I','',g_indent||'      ','Y');
Line: 2402

    li('  write_log(''update denormalized columns in hz_parties.'');');
Line: 2405

    li('  -- update denormalized columns in hz_parties.');
Line: 2408

    li('    UPDATE hz_parties');
Line: 2454

     + update party_name, customer_key in hz_parties
     +===============================================================*/

    IF l_has_party_name THEN
      Gen_PartyName (p_entity_name);
Line: 2479

     + update party_name of relationship parties
     +===============================================================*/

    IF l_has_party_name THEN
      Gen_RelationshipPartyName;
Line: 2490

     + update exception table to track attributes'  data source
     +===============================================================*/

    li('  write_log(''update exception table.'');');
Line: 2498

        li('  update_exception_table(''C'','||
           'i_party_id,'''||i_uq_attribute_name(i)||''','||
           i_uq_entity_attr_id(i)||','||
           'i_'||Format_AttributeName(i_uq_attribute_name(i))||','''||
           i_uq_winner_source(i)||''');');
Line: 2510

        li('  update_exception_table_date(''C'','||
           'i_party_id,'''||i_attribute_name_date(i)||''','||
           i_entity_attr_id_date(i)||','||
 Format_AttributeName(i_attribute_name_date(i))||');');
Line: 2520

	li(' delete hz_user_overwrite_rules where entity_attr_id = ' || i_entity_attr_id_date(i) || ' ;');
Line: 2535

     + update DQM interface table
     +
     + As per talk with Srini, right now DQM can not handle huge
     + data in interface table. User should run DQM sync program
     + after they run this program for mix-n-match.
     +===============================================================*/
    /*
    IF hz_dqm_search_util.is_dqm_available = 'T' THEN
      Gen_CodeForDQM(p_entity_name);
Line: 2588

 *  				  and use them in same insert statement as
 *				  'By Rank' attributes
 *  				~ populate the exception table for
 *  				  'By Date' attributes.
 */

PROCEDURE Gen_BulkUpdateSST (
    p_entity_name                   IN     VARCHAR2,
    p_purpose                       IN     VARCHAR2
) IS

    CURSOR c_restricted_attributes IS
      SELECT e.attribute_name, e.entity_attr_id,
             e.group_flag, s.content_source_type
      FROM
        (SELECT e.attribute_name, e.entity_attr_id, 'N' group_flag
         FROM hz_entity_attributes e
         WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
         AND e.updated_flag = 'Y'
         UNION
         SELECT e.attribute_group_name,
                MIN(entity_attr_id) entity_attr_id,
                'Y' group_flag
         FROM hz_entity_attributes e
         WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
         AND e.updated_flag = 'Y'
         AND NOT EXISTS (
           SELECT 'Y'
           FROM hz_entity_attributes e1
           WHERE e.attribute_group_name = e1.attribute_name)
         GROUP BY e.attribute_group_name) e,
        hz_select_data_sources s
      WHERE /*EXISTS (
        SELECT 'Y'
        FROM hz_select_data_sources s1
        WHERE s1.entity_attr_id = e.entity_attr_id
        AND s1.content_source_type <> 'USER_ENTERED'
        AND s1.ranking > 0 )
      AND */ s.entity_attr_id = e.entity_attr_id
      AND s.ranking > 0
      ORDER BY e.attribute_name, s.ranking;
Line: 2631

      SELECT e.attribute_name, e.entity_attr_id,
             e.group_flag, s.content_source_type
      FROM
        (SELECT e.attribute_name, e.entity_attr_id, 'N' group_flag
         FROM hz_entity_attributes e
         WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
         UNION
         SELECT e.attribute_group_name,
                MIN(entity_attr_id) entity_attr_id,
                'Y' group_flag
         FROM hz_entity_attributes e
         WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
         AND NOT EXISTS (
           SELECT 'Y'
           FROM hz_entity_attributes e1
           WHERE e.attribute_group_name = e1.attribute_name)
         GROUP BY e.attribute_group_name) e,
        hz_select_data_sources s
      WHERE /*EXISTS (
        SELECT 'Y'
        FROM hz_select_data_sources s1
        WHERE s1.entity_attr_id = e.entity_attr_id
        AND s1.content_source_type <> 'USER_ENTERED'
        AND s1.ranking > 0 )
      AND*/ s.entity_attr_id = e.entity_attr_id
      AND s.ranking > 0
      ORDER BY e.attribute_name, s.ranking;
Line: 2671

      SELECT UNIQUE s.content_source_type
      FROM hz_entity_attributes e,
           hz_select_data_sources s
      WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
      AND e.updated_flag = 'Y'
      AND e.entity_attr_id = s.entity_attr_id
      AND s.ranking > 0;
Line: 2686

      SELECT UNIQUE s.content_source_type
      FROM hz_entity_attributes e,
           hz_select_data_sources s
      WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
      AND e.entity_attr_id = s.entity_attr_id
      AND s.ranking > 0;
Line: 2695

    CURSOR c_deselected_sources IS
      SELECT s.entity_attr_id, s.content_source_type
      FROM hz_entity_attributes e,
           hz_select_data_sources s
      WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
      AND e.updated_flag = 'Y'
      AND e.entity_attr_id = s.entity_attr_id
      AND s.ranking = 0
      ORDER BY s.entity_attr_id;
Line: 2706

    i_deselected_sources            INDEXVARCHAR30List;
Line: 2709

      SELECT e.attribute_group_name, e.attribute_name
      FROM hz_entity_attributes e,
        (SELECT UNIQUE attribute_group_name
         FROM hz_entity_attributes
         WHERE entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
         GROUP BY attribute_group_name
         HAVING COUNT(*) > 1) e1
      WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
      AND e.attribute_group_name = e1.attribute_group_name
      AND e.attribute_group_name <> e.attribute_name
      AND e.updated_flag = 'Y'
      AND EXISTS (
        SELECT 'Y'
        FROM hz_select_data_sources s1
        WHERE s1.entity_attr_id = e.entity_attr_id
--        AND s1.content_source_type <> 'USER_ENTERED'
        AND s1.ranking > 0 )
        ;
Line: 2731

      SELECT e.attribute_group_name, e.attribute_name
      FROM hz_entity_attributes e,
        (SELECT UNIQUE attribute_group_name
         FROM hz_entity_attributes
         WHERE entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
         GROUP BY attribute_group_name
         HAVING COUNT(*) > 1) e1
      WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
      AND e.attribute_group_name = e1.attribute_group_name
      AND e.attribute_group_name <> e.attribute_name
      AND EXISTS (
        SELECT 'Y'
        FROM hz_select_data_sources s1
        WHERE s1.entity_attr_id = e.entity_attr_id
--        AND s1.content_source_type <> 'USER_ENTERED'
        AND s1.ranking > 0 );
Line: 2779

         SELECT distinct e.attribute_name, e.entity_attr_id
         FROM hz_entity_attributes e,
         hz_select_data_sources s
         WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
         AND EXISTS (
         SELECT 'Y'
         FROM hz_select_data_sources s1
         WHERE s1.entity_attr_id = e.entity_attr_id
         AND s1.ranking < 0 )
         AND s.entity_attr_id = e.entity_attr_id
         AND e.updated_flag = 'Y'
         AND s.ranking < 0
         ORDER BY e.attribute_name;
Line: 2807

         SELECT distinct e.attribute_name, e.entity_attr_id
         FROM hz_entity_attributes e,
         hz_select_data_sources s
         WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
         AND EXISTS (
         SELECT 'Y'
         FROM hz_select_data_sources s1
         WHERE s1.entity_attr_id = e.entity_attr_id
         AND s1.ranking < 0 )
         AND s.entity_attr_id = e.entity_attr_id
         AND s.ranking < 0
         ORDER BY e.attribute_name;
Line: 2824

      l_procedure_name := p_purpose || 'UpdateOrgSST';
Line: 2830

      l_procedure_name := p_purpose || 'UpdatePersonSST';
Line: 2901

    li(fp('i_create_update_flag')||'INDEXVARCHARlist;');
Line: 2908

    li(fp('update_start')||'NUMBER := 0;');
Line: 2909

    li(fp('update_end')||'NUMBER := 0;');
Line: 2919

     + select for restricted columns (i.e. columns have been selected)
     +
     +   SELECT ...
     +          --
     +          -- processing branch_flag.
     +          DECODE(dnb.branch_flag, NULL,
     +            DECODE(user_entered.branch_flag, NULL,
     +            NULL,
     +            user_entered.branch_flag||'%#USER_ENTERED'),
     +          dnb.branch_flag||'%#DNB') branch_flag,
     +          --
     +          -- processing ceo_name.
     +          DECODE(user_entered.ceo_name, NULL,
     +            DECODE(dnb.ceo_name, NULL,
     +            NULL,
     +            dnb.ceo_name||'%#DNB'),
     +          user_entered.ceo_name||'%#USER_ENTERED') ceo_name,
     +          --
     +          ...
     +===============================================================*/

    l_cursor_name := 'c_entity';
Line: 2945

    li('  SELECT /*+ leading(i) use_nl(sg) index(sg,hz_imp_parties_sg_n1) */');
Line: 2946

    li('decode(fnd_profile.value (''HZ_PROFILE_VERSION''),''NEW_VERSION'',''C'',''NO_VERSION'',''U'',decode(trunc(sst.effective_start_date),trunc(sysdate),''U'',''C'')) create_update_flag,');
Line: 3020

     + select normal columns (i.e. columns not in setup tables and
     + columns not selected)
     +
     +          --
     +          -- processing attribute1.
     +          sst.attribute1,
     +          --
     +          -- processing attribute2.
     +          sst.attribute2,
     +          ...
     +===============================================================*/

    FOR i IN 1..i_normal_attributes.COUNT LOOP
      l(',');
Line: 3096

       getBulkUpdateWhereCondition;
Line: 3098

       getImportUpdateWhereCondition;
Line: 3109

    li('    SELECT ''Y''');
Line: 3136

    li('ORDER BY create_update_flag, sst.party_id;');
Line: 3147

	date_cursor_update(i_entity_attr_id_date(i),
	i_attribute_name_date(i),
	p_entity_name,
	p_purpose);
Line: 3165

   li('  SELECT ''Y'' ');
Line: 3167

   li('  WHERE e.updated_flag = ''Y'' ');
Line: 3214

    li('    i_create_update_flag,');
Line: 3267

     + select attributes inside an attribute group
     +===============================================================*/

    IF ( UPPER(p_purpose) = 'BULK') THEN
      OPEN c_groups;
Line: 3341

        li('      SELECT');
Line: 3352

     + put profile ids into 2 table. 1 for create and another for update
     +===============================================================*/

    li('  create_start := 0;  create_end := -1; ');
Line: 3356

    li('  update_start := 0;  update_end := -1; ');
Line: 3359

    li('    IF i_create_update_flag(i) = ''C'' THEN');
Line: 3362

    li('      IF update_start = 0 THEN ');
Line: 3363

    li('        update_start := i; ');
Line: 3370

    li('  IF update_start > 0 AND update_end = -1 THEN update_end := subtotal; END IF;');
Line: 3373

    li('  write_log((update_end - update_start)||'' record(s) need to be updated.'');');
Line: 3385

    li('    UPDATE hz_'||p_entity_name||'_profiles ');
Line: 3403

    li('  -- insert sst profiles');
Line: 3406

    li('    INSERT INTO hz_'||p_entity_name||'_profiles (');
Line: 3418

     + column list of insert statement
     +
     +   duns_number_c,
     +   employees_total,
     +   ...
     +===============================================================*/

    FOR i IN 1..i_uq_attribute_name.COUNT LOOP
      l(',');
Line: 3450

     + value list of insert statement
     +
     +   SUBSTRB(i_duns_number_c(i),1,INSTRB(i_duns_number_c(i),'%#')-1),
     +   TO_NUMBER(SUBSTRB(i_employees_total(i),1, INSTRB(i_employees_total(i),'%#')-1)),
     +   ...
     +===============================================================*/

    Gen_CodeForWhoColumns('I','',g_indent||'      ','Y');
Line: 3512

     + update sst profiles
     +===============================================================*/

    li('  write_log(''update sst profiles.'');');
Line: 3517

    li('  -- update sst profiles');
Line: 3519

    li('  FORALL i IN update_start..update_end');
Line: 3520

    li('    UPDATE hz_'||p_entity_name||'_profiles');
Line: 3562

      li('  IF (update_end-update_start) > 0 THEN');
Line: 3578

    li('  write_log(''update denormalized columns in hz_parties.'');');
Line: 3581

    li('  -- update denormalized columns in hz_parties.');
Line: 3584

    li('    UPDATE hz_parties');
Line: 3631

     + update party_name, customer_key in hz_parties
     +===============================================================*/

    IF l_has_party_name THEN
      Gen_PartyName (p_entity_name);
Line: 3656

     + update party_name of relationship parties
     +===============================================================*/

    IF l_has_party_name THEN
      Gen_RelationshipPartyName;
Line: 3667

     + update exception table to track attributes' data source
     +===============================================================*/

    li('  write_log(''update exception table.'');');
Line: 3679

  li('  -- We need to delete only if there is setup change. If no setup change');
Line: 3680

  li('  -- and call is from regular processing API, then no DELETE is required');
Line: 3685

  li('    Write_Log(''NO setup for any entity / attribute has been updated. DELETE hz_win_source_exceps call not required.''); ');
Line: 3694

          li('  DELETE hz_win_source_exceps ');
Line: 3702

    OPEN c_deselected_sources;
Line: 3703

    FETCH c_deselected_sources BULK COLLECT INTO i_deentity_attr_id, i_deselected_sources;
Line: 3704

    CLOSE c_deselected_sources;
Line: 3712

    /* Bug 4228765 : Donot delete MRR records here as it is
 * 		     deleted in main conc program earlier
          li('  DELETE hz_win_source_exceps ');
Line: 3720

        li('  update_exception_table(''U'','||
           'i_party_id,'''||i_uq_attribute_name(i)||''','||
           i_uq_entity_attr_id(i)||','||
           'i_'||Format_AttributeName(i_uq_attribute_name(i))||','''||
           i_uq_winner_source(i)||''');');
Line: 3738

          li('  DELETE hz_win_source_exceps ');
Line: 3755

      str1 := str1||''''||i_deselected_sources(i)||'''';
Line: 3760

        li('  update_exception_table_date(''U'','||
           'i_party_id,'''||i_attribute_name_date(i)||''','||
           i_entity_attr_id_date(i)||','||
 Format_AttributeName(i_attribute_name_date(i))||');');
Line: 3770

	li(' delete hz_user_overwrite_rules where entity_attr_id = ' || i_entity_attr_id_date(i)||' ;');
Line: 3782

    Gen_WriteOutputFileForUpdate;
Line: 3785

     + update DQM interface table
     +
     + As per talk with Srini, right now DQM can not handle huge
     + data in interface table. User should run DQM sync program
     + after they run this program for mix-n-match.
     +===============================================================*/
    /*
    IF hz_dqm_search_util.is_dqm_available = 'T' THEN
      Gen_CodeForDQM(p_entity_name);
Line: 3812

    li('write_out(total||'' sst profile(s) was(were) updated.'');');
Line: 3814

    li('write_log(total||'' sst profile(s) was(were) successfully updated.'');');
Line: 3818

END Gen_BulkUpdateSST;
Line: 3850

PROCEDURE Gen_UpdateSSTRecord (
    p_entity_name             IN     VARCHAR2
) IS

    CURSOR c_restricted_attributes IS
      SELECT e.attribute_name, e.entity_attr_id,
             s.content_source_type
      FROM hz_entity_attributes e,
           hz_select_data_sources s
      WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
      AND e.attribute_name NOT IN ('BANK_CODE','BANK_OR_BRANCH_NUMBER','BRANCH_CODE')
      AND EXISTS (
        SELECT 'Y'
        FROM hz_select_data_sources s1
        WHERE s1.entity_attr_id = e.entity_attr_id
        AND s1.content_source_type <> 'USER_ENTERED'
        AND s1.ranking > 0 )
      AND s.entity_attr_id = e.entity_attr_id
      AND s.ranking > 0
      ORDER BY e.attribute_name, s.ranking;
Line: 3881

      SELECT UNIQUE s.content_source_type
      FROM hz_entity_attributes e,
           hz_select_data_sources s
      WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
      AND e.attribute_name NOT IN ('BANK_CODE','BANK_OR_BRANCH_NUMBER','BRANCH_CODE')
      AND e.entity_attr_id = s.entity_attr_id
      AND s.ranking > 0;
Line: 3895

      SELECT  e.attribute_group_name,
              DECODE(e.attribute_group_name, 'PERSON_NAME',
                     DECODE(e1.attribute_name, 'PERSON_LAST_NAME',
                            e1.entity_attr_id, null),
                     e1.attribute_name,
                     e1.entity_attr_id, null) primary_entity_attr_id,
             e1.attribute_name,
             e1.entity_attr_id
      FROM
        (SELECT attribute_group_name
         FROM hz_entity_attributes
         WHERE entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
         GROUP BY attribute_group_name
         HAVING COUNT(entity_attr_id) > 1
        ) e,
        hz_entity_attributes e1
      WHERE e1.attribute_group_name = e.attribute_group_name
      AND e1.attribute_name NOT IN ('BANK_CODE','BANK_OR_BRANCH_NUMBER','BRANCH_CODE')
      AND EXISTS (
        SELECT 'Y'
        FROM hz_select_data_sources s1
        WHERE s1.entity_attr_id = e1.entity_attr_id
        AND s1.content_source_type <> 'USER_ENTERED'
        AND s1.ranking <> 0 )
      ORDER BY e.attribute_group_name, primary_entity_attr_id;
Line: 3942

	 SELECT distinct e.attribute_name, e.entity_attr_id
	 FROM hz_entity_attributes e,
	 hz_select_data_sources s
         WHERE e.entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
         AND e.attribute_name NOT IN ('BANK_CODE','BANK_OR_BRANCH_NUMBER','BRANCH_CODE')
	 AND EXISTS (
	 SELECT 'Y'
	 FROM hz_select_data_sources s1
	 WHERE s1.entity_attr_id = e.entity_attr_id
	 AND s1.ranking < 0 )
	 AND s.entity_attr_id = e.entity_attr_id
	 AND s.ranking < 0
       ORDER BY e.attribute_name;
Line: 3958

     	SELECT  e.attribute_group_name,
              DECODE(e.attribute_group_name, 'PERSON_NAME',
                     DECODE(e1.attribute_name, 'PERSON_LAST_NAME',
                            e1.entity_attr_id, null),
                     e1.attribute_name,
                     e1.entity_attr_id, null) primary_entity_attr_id,
             e1.attribute_name,
             e1.entity_attr_id
      FROM
        (SELECT attribute_group_name
         FROM hz_entity_attributes
         WHERE entity_name = 'HZ_'||UPPER(p_entity_name)||'_PROFILES'
         GROUP BY attribute_group_name
         HAVING COUNT(entity_attr_id) > 1
        ) e,
        hz_entity_attributes e1
      WHERE e1.attribute_group_name = e.attribute_group_name
      AND EXISTS (
        SELECT 'Y'
        FROM hz_select_data_sources s1
        WHERE s1.entity_attr_id = e1.entity_attr_id
        AND s1.ranking < 0 )
      ORDER BY e.attribute_group_name, primary_entity_attr_id;
Line: 4013

      l_procedure_name := 'selectOrgHighestRankedValue';
Line: 4015

      l_procedure_name := 'selectPerHighestRankedValue';
Line: 4030

      li('SELECT ');
Line: 4292

    li(fp('p_create_update_flag')||'IN     VARCHAR2,');
Line: 4305

          li('IF p_create_update_flag = ''C'' THEN');
Line: 4393

    li(fp('p_updateable_flag_list')||'IN OUT NOCOPY HZ_MIXNM_UTILITY.INDEXVARCHAR1List,');
Line: 4422

              li('  p_updateable_flag_list('||i_group_entity_attr_id(j)||') := ''N'';');
Line: 4436

          li('IF p_updateable_flag_list.EXISTS('||i_group_entity_attr_id(i)||') AND');
Line: 4437

          li('   p_updateable_flag_list('||i_group_entity_attr_id(i)||') = ''Y''');
Line: 4455

          li('    p_updateable_flag_list('||i_group_entity_attr_id(i)||') := ''Y'';');
Line: 4462

        li('IF p_updateable_flag_list.EXISTS('||i_uq_entity_attr_id(i)||') AND');
Line: 4463

        li('   p_updateable_flag_list('||i_uq_entity_attr_id(i)||') = ''Y''');
Line: 4471

        li('IF p_updateable_flag_list.EXISTS('||i_entity_attr_id_date(i)||') AND');
Line: 4472

        li('   p_updateable_flag_list('||i_entity_attr_id_date(i)||') = ''Y''');
Line: 4488

    l_procedure_name := 'updateSSTRecord';
Line: 4492

    li(fp('p_create_update_flag')||'IN	VARCHAR2,');
Line: 4496

    li(fp('p_updateable_flag_list')||'IN OUT NOCOPY HZ_MIXNM_UTILITY.INDEXVARCHAR1List,');
Line: 4510

      li('   p_updateable_flag_list.COUNT > 0');
Line: 4513

        li('  selectOrgHighestRankedValue(');
Line: 4515

        li('  selectPerHighestRankedValue(');
Line: 4523

        li('IF p_updateable_flag_list.EXISTS('||i_uq_entity_attr_id(i)||') AND');
Line: 4524

        li('   p_updateable_flag_list('||i_uq_entity_attr_id(i)||') = ''Y''');
Line: 4557

        li('IF p_updateable_flag_list.EXISTS('||i_uq_entity_attr_id(l_index1)||') AND');
Line: 4558

        li('   p_updateable_flag_list('||i_uq_entity_attr_id(l_index1)||') = ''Y'' AND');
Line: 4559

        li('   (NOT p_updateable_flag_list.EXISTS('||i_uq_entity_attr_id(l_index2)||') OR');
Line: 4560

        li('    p_updateable_flag_list('||i_uq_entity_attr_id(l_index2)||') = ''N'')');
Line: 4562

        li('  p_updateable_flag_list('||i_uq_entity_attr_id(l_index2)||') := ''Y'';');
Line: 4574

        li('IF p_updateable_flag_list.EXISTS('||i_uq_entity_attr_id(l_index2)||') AND');
Line: 4575

        li('   p_updateable_flag_list('||i_uq_entity_attr_id(l_index2)||') = ''Y'' AND');
Line: 4576

        li('   (NOT p_updateable_flag_list.EXISTS('||i_uq_entity_attr_id(l_index1)||') OR');
Line: 4577

        li('    p_updateable_flag_list('||i_uq_entity_attr_id(l_index1)||') = ''N'')');
Line: 4579

        li('  p_updateable_flag_list('||i_uq_entity_attr_id(l_index1)||') := ''Y'';');
Line: 4606

        li('IF p_updateable_flag_list.EXISTS('||i_entity_attr_id_date(i)||') AND');
Line: 4607

        li('   p_updateable_flag_list('||i_entity_attr_id_date(i)||') = ''Y''');
Line: 4609

	li('  IF p_create_update_flag = ''U'' THEN');
Line: 4627

END Gen_UpdateSSTRecord;
Line: 4679

    Gen_BulkUpdateSST('organization', 'Bulk');
Line: 4682

    Gen_BulkUpdateSST('person', 'Bulk');
Line: 4686

    Gen_BulkUpdateSST('organization', 'Import');
Line: 4689

    Gen_BulkUpdateSST('person', 'Import');
Line: 4732

    Gen_UpdateSSTRecord('organization');
Line: 4733

    Gen_UpdateSSTRecord('person');
Line: 4751

    li('  -- to update interface table so the affected parties');
Line: 4757

    li('    INSERT INTO hz_dqm_sync_interface (');
Line: 4778

      li('    SELECT');
Line: 4788

      li('    SELECT');