DBA Data[Home] [Help]

APPS.MSD_COLLECT_LEVEL_VALUES SQL Statements

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

Line: 29

Procedure  Delete_duplicate(p_instance_id in number, p_dest_table in varchar2);
Line: 31

Procedure Delete_Childless_Parent_All (	errbuf              OUT NOCOPY VARCHAR2,
					retcode             OUT NOCOPY VARCHAR2,
					p_instance          in  VARCHAR2);
Line: 35

Procedure Delete_Childless_Parent (
					errbuf              OUT NOCOPY VARCHAR2,
					retcode             OUT NOCOPY VARCHAR,
					p_instance_id       in number,
					p_level_id          in number);
Line: 40

				--	p_dest_table        in varchar2);   Bug# 4919130 - Always delete childless parents from staging table.
Line: 117

        /* Added logic to delete duplicate data */
        Delete_duplicate(p_instance_id, MSD_COMMON_UTILITIES.LEVEL_VALUES_STAGING_TABLE);
Line: 120

        /* Delete duplicate level association from staging table */
        Delete_duplicate_lvl_assoc(errbuf, retcode, p_instance_id);
Line: 149

		Delete_duplicate(p_instance_id ,
                                 MSD_COMMON_UTILITIES.LEVEL_VALUES_STAGING_TABLE);
Line: 151

                Delete_duplicate_lvl_assoc(errbuf, retcode, p_instance_id);
Line: 170

			p_update_lvl_table  IN  NUMBER) IS
x_statement VARCHAR2(2000) := NULL ;
Line: 182

x_delete_flag   varchar2(1) := 'Y' ;
Line: 206

select  distinct
	hierarchy_id,
	relationship_view,
        level_value_column,
        level_value_pk_column,
        nvl(level_value_desc_column,level_value_column) level_value_desc_column,
        parent_value_column,
        parent_value_pk_column,
        nvl(parent_value_desc_column, parent_value_column) parent_value_desc_column
from 	msd_hierarchy_levels
where 	level_id = p_level_id
and    	parent_level_id = p_parent_level_id
and     plan_type is null; --vinekuma
Line: 229

	*	   which table to insert into - whether the staging
	*	   table or the fact table
	*	3. Get the view that hold the association and the
	*	   corresponding column names.
	*	4. Set the Save Point and delete the already existing
	*	   data in the level values are the staging table.
	*	5. Insert the new values from the association views
	*	6. Commit
	************************************************************/

        retcode :=0;
Line: 278

	      SELECT hierarchy_name INTO p_hierarchy_name
	      FROM   msd_hierarchies
	      WHERE  hierarchy_id = Relationship_Rec.hierarchy_id
	      AND    plan_type is null; --vinekuma
Line: 334

			p_update_lvl_table         => p_update_lvl_table,
			/* OPM Comment Rajesh Patangya */
                        p_delete_flag              => x_delete_flag,
                        p_seq_num                  => p_seq_num );
Line: 351

                 x_delete_flag   := 'N' ;
Line: 368

			p_update_lvl_table         => p_update_lvl_table,
			/* OPM Comment Rajesh Patangya */
                        p_delete_flag              => x_delete_flag,
                        p_seq_num                  => p_seq_num );
Line: 405

/* lvl_table needs to be updated only once - this is the indicator */
x_update_lvl_table NUMBER := 1;
Line: 413

select distinct level_id, parent_level_id, level_type_code
from msd_hierarchy_levels_v
where level_id = p_level_id
order by level_type_code, level_id;
Line: 432

		p_update_lvl_table => x_update_lvl_table);
Line: 434

	x_update_lvl_table := 0;
Line: 449

  /* Bug# 5530511 - Delete_Childless_Parent_All should be called after
   *                the call to fix_orphans
   */
  Delete_Childless_Parent_All (	errbuf, retcode, p_instance_id);
Line: 482

select level_id, parent_level_id, level_type_code
from msd_hierarchy_levels_v
where hierarchy_id = p_hierarchy_id
order by level_type_code, level_id;
Line: 489

select distinct level_id, level_type_code
from msd_hierarchy_levels_v
where hierarchy_id = p_hierarchy_id
order by level_type_code, level_id;
Line: 495

select distinct OWNING_DIMENSION_CODE
from msd_hierarchy_levels_v
where hierarchy_id = p_hierarchy_id;
Line: 514

		p_update_lvl_table => 0);
Line: 524

		p_update_lvl_table => 1);
Line: 546

  /* Bug# 5530511 - Delete_Childless_Parent_All should be called after
   *                the call to fix_orphans
   */
   Delete_Childless_Parent_ALL ( errbuf, retcode, p_instance_id);
Line: 583

select distinct level_id, parent_level_id, level_type_code
from msd_hierarchy_levels_v
where owning_dimension_code = p_dimension_code
order by level_type_code, level_id;
Line: 590

select distinct level_id, level_type_code
from msd_hierarchy_levels_v
where owning_dimension_code = p_dimension_code
order by level_type_code, level_id;
Line: 610

		p_update_lvl_table => 0);
Line: 619

		p_update_lvl_table => 1);
Line: 642

  /* Bug# 5530511 - Delete_Childless_Parent_All should be called after
   *                the call to fix_orphans
   */
   Delete_Childless_Parent_ALL ( errbuf, retcode, p_instance_id);
Line: 672

select distinct owning_dimension_code
from msd_dp_hierarchies_v
where demand_plan_id = p_demand_plan_id
and   dp_dimension_code = p_dimension_code ;
Line: 712

select distinct dp_dimension_code
from msd_dp_hierarchies_v
where demand_plan_id = p_demand_plan_id ;
Line: 750

select lookup_code
from fnd_lookup_values_vl
where lookup_type = 'MSD_DIMENSIONS' ;
Line: 785

  been inserted in the desination table.
***************************************************************/
procedure fix_orphans(p_instance_id    in number,
                      p_level_id       in number,
                      p_dest_table     in varchar2,
                      p_dest_ass_table in varchar2,
                      p_hierarchy_id   in number) IS

Cursor Parent_Levels(p_lvl_id IN NUMBER) is
select distinct parent_level_id
from msd_hierarchy_levels
where level_id = p_lvl_id
and hierarchy_id = nvl(p_hierarchy_id, hierarchy_id);
Line: 810

	         Note that even though this level value has not yet been inserted
                 into the destination table, it is okay to add an association
                 because the value itself will certainly be added in the next
                 pass over the parent level.
	   */
           v_other_pk := to_char(msd_sr_util.get_null_pk);
Line: 818

	   /* Insert association for orphans */
           /* VM Logic : Find orphans using MINUS set between
              records in level_values for Level in consideration and
              records in level_Association for level and parent level in consideration
           */

	   v_sql_stmt := 'insert into ' || p_dest_ass_table || ' (' ||
              'instance, ' ||
              'level_id, ' ||
              'sr_level_pk, ' ||
              'parent_level_id, ' ||
              'sr_parent_level_pk, ' ||
              'last_update_date, ' ||
              'last_updated_by, ' ||
              'creation_date, ' ||
              'created_by ) ' ||
              'select  ''' ||
              p_instance_id ||''', ' ||
              p_level_id || ', ' ||
              'sr_level_pk, ' ||
              v_parent_level_id || ', ''' ||
              v_other_pk || ''', ' ||
              'sysdate, ' ||
              FND_GLOBAL.USER_ID || ', ' ||
              'sysdate, ' ||
              FND_GLOBAL.USER_ID ||
              ' from ' || p_dest_table || ' mlv ' ||
              ' where level_id = ' || p_level_id ||
              '   and instance = ' || p_instance_id ||
              ' minus ' ||
              'select  ''' ||
              p_instance_id ||''', ' ||
              p_level_id || ', ' ||
              'sr_level_pk, ' ||
              v_parent_level_id || ', ''' ||
              v_other_pk || ''', ' ||
              'sysdate, ' ||
              FND_GLOBAL.USER_ID || ', ' ||
              'sysdate, ' ||
              FND_GLOBAL.USER_ID ||
              ' from ' || p_dest_ass_table || ' amlv ' ||
              ' where level_id = ' || p_level_id ||
              '   and instance = ' || p_instance_id ||
              '   and parent_level_id = ' || v_parent_level_id;
Line: 863

 	   -- insert into msd_test values(v_sql_stmt) ;
Line: 895

Procedure  Delete_duplicate(p_instance_id in number, p_dest_table in varchar2) is

lb_FetchComplete  BOOLEAN := FALSE;
Line: 909

Cursor c_Update_Level_Values
is
select level_id, sr_level_pk,system_attribute1,system_attribute2,dp_enabled_flag
from msd_st_level_values a
where a.instance = p_instance_id
and rowid = ( select max(rowid)
              from msd_st_level_values b
              where a.instance = b.instance
              and a.level_id = b.level_id
              and a.sr_level_pk = b.sr_level_pk
              and b.system_attribute1 is not null);  -- assuming here that if there exist more than one record
Line: 935

       OPEN  c_Update_Level_Values;
Line: 936

             IF (c_Update_Level_Values%ISOPEN) THEN

                LOOP

                   IF (lb_FetchComplete) THEN
                     EXIT;
Line: 944

                   FETCH c_Update_Level_Values BULK COLLECT INTO
                                         lb_level_id,
                                         lb_sr_level_pk,
                                         lb_system_attribute1,
                                         lb_system_attribute2,
                                         lb_dp_enabled_flag
                   LIMIT ln_rows_to_fetch;
Line: 953

                   IF (c_Update_Level_Values%NOTFOUND) THEN
                      lb_FetchComplete := TRUE;
Line: 958

                   if c_Update_Level_Values%ROWCOUNT > 0  then

                         FORALL j IN lb_level_id.FIRST..lb_level_id.LAST
                         update msd_st_level_values
                         set system_attribute1 = lb_system_attribute1(j),
                             system_attribute2 = lb_system_attribute2(j),
                             dp_enabled_flag   = lb_dp_enabled_flag(j)
                         where instance = p_instance_id
                         and   level_id = lb_level_id(j)
                         and   sr_level_pk = lb_sr_level_pk(j)
                         and   system_attribute1 is null;
Line: 976

             END IF;  --IF (c_Update_Level_Values%ISOPEN) THEN
Line: 977

           CLOSE c_Update_Level_Values;
Line: 981

  /* This procedure deletes duplicate records from staging level_values
     Key - Instance + Level_Id  + SR_LEVEL_PK
  */

  if p_dest_table = MSD_COMMON_UTILITIES.LEVEL_VALUES_STAGING_TABLE then
    delete from msd_st_level_values a where
    a.instance = p_instance_id and
    rowid <> (select max(rowid) from msd_st_level_values b
              where a.instance = b.instance
              and a.level_id = b.level_id
              and a.sr_level_pk = b.sr_level_pk);
Line: 996

Procedure  Delete_duplicate_lvl_assoc( errbuf              OUT NOCOPY VARCHAR2,
                                       retcode             OUT NOCOPY VARCHAR2,
                                       p_instance_id in number) is

cursor c_duplicate is
select level_id, sr_level_pk, parent_level_id
from msd_st_level_associations
where  instance = p_instance_id
group by level_id, sr_level_pk, parent_level_id
having count(*) > 1;
Line: 1017

  /* This procedure deletes duplicate records from staging level association
     Key - Instance + Child_Level_Id  + SR_LEVEL_PK + Parent_Level_ID
  */

     OPEN  c_duplicate;
Line: 1027

           delete from msd_st_level_associations a where
           a.instance = p_instance_id and
           a.level_id = a_child_level_id(i) and
           a.sr_level_pk = a_sr_level_pk(i) and
           a.parent_level_id = a_parent_level_id(i) and
           rowid <> (select rowid from msd_st_level_associations b
                     where b.instance = p_instance_id and
                           b.level_id = a_child_level_id(i) and
                           b.sr_level_pk = a_sr_level_pk(i) and
                           b.parent_level_id = a_parent_level_id(i) and
                           rownum < 2);
Line: 1048

END Delete_duplicate_lvl_assoc;
Line: 1051

  Procedure Delete_Childless_Parent_ALL

	This procedure will call delete_childless_parent for all level_id and
	instance.

******************************************************************************************/
Procedure Delete_Childless_Parent_ALL (	errbuf              OUT NOCOPY VARCHAR2,
					retcode             OUT NOCOPY VARCHAR2,
					p_instance          in  VARCHAR2) IS

/* Cursor for staging table */
CURSOR c_st_level is
   select distinct a.instance, a.level_id
   from msd_st_level_values a, msd_levels b
   where a.level_id = b.level_id and
   a.instance <> 0 and
   b.level_type_code = 3 and
   a.instance = p_instance;
Line: 1072

/* Bug# 4919130 - Always delete childless parents from staging table.
CURSOR c_level is
   select distinct a.instance, a.level_id
   from msd_level_values a, msd_levels b
   where a.level_id = b.level_id and
   a.instance <> 0 and
   b.level_type_code = 3 and
   a.instance = p_instance;
Line: 1088

  /* Bug# 4919130 - Always delete childless parents from staging table.
  IF (fnd_profile.value('MSD_ONE_STEP_COLLECTION') = 'Y') THEN

     l_dest_table :=  MSD_COMMON_UTILITIES.LEVEL_VALUES_FACT_TABLE;
Line: 1094

        Delete_Childless_Parent (	errbuf,
					retcode,
					Level_Rec.instance,
					Level_Rec.level_id,
					l_dest_table);
Line: 1102

   /* Bug# 4919130 - Always delete childless parents from staging table.
   ELSE
     l_dest_table := MSD_COMMON_UTILITIES.LEVEL_VALUES_STAGING_TABLE ;
Line: 1108

        Delete_Childless_Parent (	errbuf,
					retcode,
					Level_Rec.instance,
					Level_Rec.level_id);
Line: 1112

				--	l_dest_table);        Bug# 4919130 - Always delete childless parents from staging table.
Line: 1114

   /* Bug# 4919130 - Always delete childless parents from staging table.
   END IF;
Line: 1119

END Delete_Childless_Parent_ALL;
Line: 1126

  Procedure Delete_Childless_Parent

	This procedure will delete any childless parent level value.
	First, We will determine whether destination talbe is Fact or Staging, then
	Navigate level_value from either (msd_st_level_values or msd_level_values).
	Check whether that level_id exist in level association table as
	parent level id.
	If it does, then navigate next level id, otherwise, delete it.

******************************************************************************************/
Procedure Delete_Childless_Parent (
					errbuf              OUT NOCOPY VARCHAR2,
					retcode             OUT NOCOPY VARCHAR,
					p_instance_id       in number,
					p_level_id          in number) IS
				--	p_dest_table        in varchar2) IS      Bug# 4919130 - Always delete childless parents from staging table.

CURSOR c_childless_parent is
   select level_id, sr_level_pk
   from msd_backup_level_values
   where instance = '-999' and level_pk = -999;
Line: 1154

   delete from msd_backup_level_values
   where instance = '-999' and level_pk = -999;
Line: 1158

   /* Bug# 4919130 - Always delete childless parents from staging table.
   IF (p_dest_table = MSD_COMMON_UTILITIES.LEVEL_VALUES_STAGING_TABLE) THEN
   */

      insert into msd_backup_level_values (instance , level_id, sr_level_pk, level_pk )
                  select '-999' , level_id, sr_level_pk, -999
                  from msd_st_level_values
                  where instance = p_instance_id and level_id = p_level_id
                  minus
                  select '-999' , parent_level_id, sr_parent_level_pk, -999
                  from msd_st_level_associations
                  where instance = p_instance_id and parent_level_id = p_level_id ;
Line: 1171

      delete from msd_st_level_values a
      where
        instance = p_instance_id and
        level_id = p_level_id and
	exists (select 1 from msd_backup_level_values b
            where b.instance = '-999' and b.level_id = a.level_id and
            b.sr_level_pk = a.sr_level_pk and level_pk = -999);
Line: 1180

   /* Bug# 4919130 - Always delete childless parents from staging table.
   ELSIF (p_dest_table = MSD_COMMON_UTILITIES.LEVEL_VALUES_FACT_TABLE) THEN

      insert into msd_backup_level_values (instance , level_id, sr_level_pk, level_pk )
                  select '-999' , level_id, sr_level_pk, -999
                  from msd_level_values
                  where instance = p_instance_id and level_id = p_level_id
                  minus
                  select '-999' , parent_level_id, sr_parent_level_pk, -999
                 from msd_level_associations
                  where instance = p_instance_id and parent_level_id = p_level_id ;
Line: 1192

      delete from msd_level_values a
      where
        instance = p_instance_id and
        level_id = p_level_id and
	exists (select 1 from msd_backup_level_values b
                where b.instance = '-999' and b.level_id = a.level_id and
                b.sr_level_pk = a.sr_level_pk and level_pk = -999);
Line: 1211

                                          Childless_rec.level_id || ' were deleted.');
Line: 1221

      fnd_file.put_line(fnd_file.log, l_count ||' childless level values deleted.' );
Line: 1225

   delete from msd_backup_level_values
   where level_pk = -999 and instance = '-999';
Line: 1232

		fnd_file.put_line(fnd_file.log, 'Error in Delete_Childless_Parent.');
Line: 1235

END Delete_Childless_Parent;