DBA Data[Home] [Help]

APPS.HZ_MIXNM_DYNAMIC_PKG_GENERATOR SQL Statements

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

Line: 139

	SELECT REPLACE(l_frmt_actual_content_source,':','_COLON_')
	INTO l_frmt_actual_content_source
	FROM DUAL;
Line: 143

	SELECT REPLACE(l_frmt_actual_content_source,'.','_PERIOD_')
	INTO l_frmt_actual_content_source
	FROM DUAL;
Line: 147

    SELECT REPLACE(l_frmt_actual_content_source,'-','_HYPHEN_')
	INTO l_frmt_actual_content_source
	FROM DUAL;
Line: 155

		SELECT substr(l_frmt_actual_content_source,1,25)||substr(rn,1,3)
		INTO l_frmt_actual_content_source
		FROM
		 (SELECT ROWNUM rn,orig_system os FROM hz_orig_systems_b ) a
		WHERE os = p_actual_content_source;
Line: 191

PROCEDURE getBulkUpdateWhereCondition
IS
BEGIN

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

END getBulkUpdateWhereCondition;
Line: 203

PROCEDURE getImportUpdateWhereCondition
IS
BEGIN

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

END getImportUpdateWhereCondition;
Line: 361

   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, (
          --Bug 15893080 - Remove direct access from all_tab_columns
		  /*
		  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')
			*/
             select col.column_name
            from  user_synonyms syn
                  , dba_tab_columns col
           where syn.synonym_name = 'HZ_PARTIES'
           and col.owner      = syn.table_owner
           and col.table_name  = syn.table_name
             and exists (
                 select null
                   from  user_synonyms syn
                      , dba_tab_columns col2
                  where col2.owner      = syn.table_owner
                  and col2.table_name  = syn.table_name
                  and col.column_name = col2.column_name
                  and  syn.synonym_name  = 'HZ_' ||upper (p_entity_name) || '_PROFILES')
                  and col.column_name not like 'ATTRIBUTE%'
                  and col.column_name not like 'GLOBAL_ATTRIBUTE%'
                  and col.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: 438

      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: 745

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

    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: 788

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

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

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

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

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

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

    ELSE -- IF p_insert_update_flag = 'I' THEN

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

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

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

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

 *   				        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: 1054

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

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

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

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

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

    l_procedure_name := 'update_rel_party_name';
Line: 1126

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

    li('  UPDATE hz_parties');
Line: 1161

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

    l_procedure_name := 'update_exception_table';
Line: 1167

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

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

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

    li('    DELETE hz_win_source_exceps');
Line: 1234

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

    li('    UPDATE hz_win_source_exceps');
Line: 1248

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

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

    li('    SELECT');
Line: 1270

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

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

    l_procedure_name := 'update_exception_table_date';
Line: 1289

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

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

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

    li('    UPDATE hz_win_source_exceps');
Line: 1334

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

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

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

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

PROCEDURE Gen_WriteOutputFileForUpdate IS
BEGIN

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

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

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

END Gen_WriteOutputFileForUpdate;
Line: 1473

 * 	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: 1521

    li('  SELECT ');
Line: 1530

      li('( SELECT ');
Line: 1532

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

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

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

 * 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: 1642

    li('  SELECT ');
Line: 1651

    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: 1656

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

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

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

END date_cursor_update;
Line: 1720

 *  				  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: 1772

      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: 1782

      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: 1830

         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: 1926

     + 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: 1951

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

     + 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: 2117

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

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

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

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

    OPEN c_groups;
Line: 2358

        li('      SELECT');
Line: 2381

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

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

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

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

     + 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: 2502

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

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

    li('    UPDATE hz_parties');
Line: 2554

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

    IF l_has_party_name THEN
      Gen_PartyName (p_entity_name);
Line: 2579

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

    IF l_has_party_name THEN
      Gen_RelationshipPartyName;
Line: 2590

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

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

        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: 2610

        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: 2620

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

     + 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: 2688

 *  				  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: 2731

      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: 2771

      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: 2786

      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: 2795

    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: 2806

    i_deselected_sources            INDEXVARCHAR30List;
Line: 2809

      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: 2831

      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: 2880

         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: 2908

         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: 2925

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

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

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

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

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

     + 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: 3046

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

    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: 3121

     + 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: 3197

       getBulkUpdateWhereCondition;
Line: 3199

       getImportUpdateWhereCondition;
Line: 3210

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

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

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

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

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

    li('    i_create_update_flag,');
Line: 3368

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

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

        li('      SELECT');
Line: 3453

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

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

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

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

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

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

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

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

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

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

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

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

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

     + 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: 3605

	--In ImportUpdatePersonSST  procedure person_name update is added.
    IF UPPER(p_purpose) = 'IMPORT' AND UPPER(p_entity_name) =  'PERSON' THEN
	   l('');
Line: 3613

	   li('    UPDATE hz_person_profiles');
Line: 3637

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

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

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

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

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

	--In ImportUpdatePersonSST  API person_name update is added.
	IF UPPER(p_purpose) = 'IMPORT' AND UPPER(p_entity_name) =  'PERSON' THEN
	   l('');
Line: 3692

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

	   li('    UPDATE hz_person_profiles');
Line: 3710

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

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

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

    li('    UPDATE hz_parties');
Line: 3779

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

    IF l_has_party_name THEN
      Gen_PartyName (p_entity_name);
Line: 3799

	--In ImportUpdatePersonSST  API party_name update is added.
	IF UPPER(p_purpose) = 'IMPORT' AND UPPER(p_entity_name) =  'PERSON' THEN
	   l('');
Line: 3806

       li('    UPDATE hz_parties');
Line: 3824

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

    IF l_has_party_name THEN
      Gen_RelationshipPartyName;
Line: 3835

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

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

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

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

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

          li('  DELETE hz_win_source_exceps ');
Line: 3870

    OPEN c_deselected_sources;
Line: 3871

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

    CLOSE c_deselected_sources;
Line: 3880

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

        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: 3906

          li('  DELETE hz_win_source_exceps ');
Line: 3923

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

        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: 3938

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

    Gen_WriteOutputFileForUpdate;
Line: 3953

     + 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: 3980

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

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

END Gen_BulkUpdateSST;
Line: 4018

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: 4049

      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: 4063

      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: 4110

	 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: 4126

     	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: 4181

      l_procedure_name := 'selectOrgHighestRankedValue';
Line: 4183

      l_procedure_name := 'selectPerHighestRankedValue';
Line: 4198

      li('SELECT ');
Line: 4460

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

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

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

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

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

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

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

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

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

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

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

    l_procedure_name := 'updateSSTRecord';
Line: 4660

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

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

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

        li('  selectOrgHighestRankedValue(');
Line: 4683

        li('  selectPerHighestRankedValue(');
Line: 4691

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

END Gen_UpdateSSTRecord;
Line: 4847

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

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

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

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

    Gen_UpdateSSTRecord('organization');
Line: 4901

    Gen_UpdateSSTRecord('person');
Line: 4919

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

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

      li('    SELECT');
Line: 4956

      li('    SELECT');