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

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

        /* 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: 177

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

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

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

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

select  distinct

	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
and      relationship_view is not null;
Line: 250

select  distinct
	hierarchy_id
from 	msd_hierarchy_levels
where	level_id = p_level_id
and	parent_level_id = p_parent_level_id
and	relationship_view is null;
Line: 266

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

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

                 x_delete_flag   := 'N' ;
Line: 382

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

		select hierarchy_name INTO p_hierarchy_name
		FROM msd_hierarchies
		WHERE hierarchy_id = Null_Relationship_Rec.hierarchy_id;
Line: 436

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

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

		p_update_lvl_table => x_update_lvl_table);
Line: 465

	x_update_lvl_table := 0;
Line: 480

  /* 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: 522

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

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

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

		p_update_lvl_table => 0);
Line: 564

		p_update_lvl_table => 1);
Line: 586

  /* 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: 623

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

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

SELECT COUNT(*)
FROM
  (SELECT DISTINCT level_id,
     parent_level_id
   FROM msd_hierarchy_levels_v
   WHERE owning_dimension_code = p_dimension_code
   AND level_id = p_level_id);
Line: 691

		p_update_lvl_table => 0);
Line: 700

		p_update_lvl_table => 1);
Line: 725

  /* 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: 755

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

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

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

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

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

	   /* 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: 946

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

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

lb_FetchComplete  BOOLEAN := FALSE;
Line: 992

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

       OPEN  c_Update_Level_Values;
Line: 1019

             IF (c_Update_Level_Values%ISOPEN) THEN

                LOOP

                   IF (lb_FetchComplete) THEN
                     EXIT;
Line: 1027

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

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

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

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

           CLOSE c_Update_Level_Values;
Line: 1064

  /* 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: 1079

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

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

     OPEN  c_duplicate;
Line: 1110

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

END Delete_duplicate_lvl_assoc;
Line: 1134

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

/* 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: 1171

  /* 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: 1177

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

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

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

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

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

END Delete_Childless_Parent_ALL;
Line: 1209

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

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

   /* 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: 1254

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

          delete from msd_st_level_associations st_a
 	       where
 	         instance = p_instance_id and
 	         level_id = p_level_id and
 	         exists (select 1 from msd_backup_level_values st_b
 	                  where st_b.instance = '-999' and st_b.level_id = st_a.level_id and
 	                  st_b.sr_level_pk = st_a.sr_level_pk and level_pk = -999);
Line: 1271

   /* 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: 1283

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

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

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

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

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

END Delete_Childless_Parent;