DBA Data[Home] [Help]

APPS.MSD_LIABILITY SQL Statements

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

Line: 107

	        p_update_lvl_table  IN  NUMBER
		      );
Line: 127

 /* This procedure deletes duplicate level Values in the Level Association Table*/
Procedure  Delete_duplicate_lvl_assoc( errbuf              OUT NOCOPY VARCHAR2,
                                       retcode             OUT NOCOPY VARCHAR2,
                                       p_plan_id in number);
Line: 132

  /* This procedure deletes duplicate level Values in the Level Value  Table*/
Procedure  Delete_duplicate(p_plan_id in number, p_dest_table in varchar2);
Line: 150

 /* This procedure does the actual insert of Level values into fact and association table */
Procedure translate_level_parent_values(
                        errbuf                          OUT NOCOPY VARCHAR2,
                        retcode                         OUT NOCOPY VARCHAR2,
                        p_source_table                  IN  VARCHAR2,
                        p_dest_table                    IN  VARCHAR2,
                        p_plan_id                   IN  NUMBER,
                        p_level_id                      IN  NUMBER,
                        p_level_value_column            IN  VARCHAR2,
                        p_level_value_pk_column         IN  VARCHAR2,
                        p_level_value_desc_column       IN  VARCHAR2,
                        p_parent_level_id               IN  NUMBER,
                        p_parent_value_column           IN  VARCHAR2,
                        p_parent_value_pk_column        IN  VARCHAR2,
                        p_parent_value_desc_column      IN  VARCHAR2,
	        p_update_lvl_table		IN  NUMBER,
                        p_delete_flag                   IN  VARCHAR2,
                        p_seq_num                       IN  NUMBER);
Line: 199

                        p_delete_flag                   IN  VARCHAR2);
Line: 228

select calculate_liability
  from msc_plans
 where plan_id = p_plan_id;
Line: 265

     update msd_demand_plans
          set valid_flag = 1
          where demand_plan_id = p_liability_plan_id ;
Line: 279

          update msd_demand_plans
               set valid_flag = 0
               where demand_plan_id = p_liability_plan_id ;
Line: 300

/* or updates an existing Plan   */
/*2.  Validates the demand Plan*/
/*3. Collects Liability Level Values */
/*4. Checks if a Gregoria Calendar exist for plan Start Date and end Date */
/*and generates if not available */
/* 5. Calls the demand Plan buildApi  to buid the Demand Plan Cube in Olap */


Procedure run_liability_flow(
                        errbuf              OUT NOCOPY VARCHAR2,
                        retcode             OUT NOCOPY VARCHAR2,
                        p_plan_id        IN  NUMBER
                       ) IS


x_liab_plan_id NUMBER ;
Line: 367

       	/*  This preprocessor updates the Agreement details for the  forecast liability views */

       	 MSD_COMMON_UTILITIES_LB. liability_preprocessor ( p_plan_id ) ;
Line: 422

              select mdsol.LEVEL_ID , mds.scenario_id   into  x_prev_liab_calc_level , x_scenario_id   from
			MSD_DP_SCENARIO_OUTPUT_LEVELS mdsol ,
			msd_dp_scenarios mds
			where
			mds.demand_plan_id = mdsol.demand_plan_id and
			mds.scenario_id = mdsol.scenario_id
			and mds.demand_plan_id =x_liab_plan_id
			and mds.scenario_designator = 'TOTAL_LIABILITY'
			and mdsol.level_id in ( 1,2) ;
Line: 434

            /* update the output level of the scenario */
             update MSD_DP_SCENARIO_OUTPUT_LEVELS
            set level_id = x_liab_calc_level
            where  level_id  = x_prev_liab_calc_level
            and  demand_plan_id = x_liab_plan_id
            and scenario_id =  x_scenario_id  ;
Line: 441

            display_message( 'The the output level of the scenario will be updated '  ,WARNING );
Line: 445

         display_message( 'The the output level of the scenario will be updated '  ,WARNING );
Line: 457

                                                select mdsol.LEVEL_ID , mds.scenario_id   into  x_prev_liab_calc_level , x_scenario_id   from
			MSD_DP_SCENARIO_OUTPUT_LEVELS mdsol ,
			msd_dp_scenarios mds
			where
			mds.demand_plan_id = mdsol.demand_plan_id and
			mds.scenario_id = mdsol.scenario_id
			and mds.demand_plan_id =x_liab_plan_id
			and mds.scenario_designator = 'TOTAL_LIABILITY'
			and mdsol.level_id in ( 1,2) ;
Line: 470

            /* update the output level of the scenario */
            update MSD_DP_SCENARIO_OUTPUT_LEVELS
            set level_id = x_liab_calc_level
            where  level_id  = x_prev_liab_calc_level
            and  demand_plan_id = x_liab_plan_id
            and scenario_id =  x_scenario_id  ;
Line: 501

                  update msd_demand_plans  set plan_start_date =    x_plan_start_date , plan_end_date = x_plan_end_date
                  where   demand_plan_id =    x_liab_plan_id ;
Line: 504

                 UPDATE msd_dp_parameters set start_date = x_plan_start_date , end_date = x_plan_end_date
       	 WHERE parameter_type in ( 'MSD_LIAB_OPEN_PO' , 'MSD_LIAB_FORECAST' ,'MSD_LIAB_FCST_DEMAND')
       	 and demand_plan_id =    x_liab_plan_id   ;
Line: 509

       	/*UPDATE msd_dp_parameters SET PARAMETER_NAME = x_liab_plan_name
       	 WHERE demand_plan_id =    x_liab_plan_id    ; */
Line: 524

                  update  msd_demand_plans set valid_flag = 1  where liab_plan_id = p_plan_id ;
Line: 535

                  update  msd_demand_plans set valid_flag = 1  where liab_plan_id = p_plan_id ;
Line: 543

       	 retcode := MSD_COMMON_UTILITIES_LB.liability_plan_update( x_liab_plan_id ) ;
Line: 585

       	 UPDATE msd_dp_parameters set start_date = x_plan_start_date , end_date = x_plan_end_date
       	 WHERE parameter_type in ( 'MSD_LIAB_OPEN_PO' , 'MSD_LIAB_FORECAST' ,'MSD_LIAB_FCST_DEMAND')
       	 and demand_plan_id =    x_liab_plan_id   ;
Line: 599

        Select  count(*)  into x_cal_no_of_days
        from msd_time
        where calendar_type = 1 and day  between
         x_plan_start_date and x_plan_end_date
         ;
Line: 608

            display_message( 'Deleteing  Gergorian Calendar between  '||x_plan_start_date||'---'||x_plan_end_date , DEBUG);
Line: 609

           delete from msd_time where  calendar_type = 1 and trunc( day, 'DD')  between trunc( x_plan_start_date, 'DD')   and  trunc( x_plan_end_date , 'DD')  ;
Line: 637

                update  msd_demand_plans set valid_flag = 1  where liab_plan_id = p_plan_id ;
Line: 644

                update  msd_demand_plans set valid_flag = 0 where liab_plan_id = p_plan_id ;
Line: 664

               Select  DP_BUILD_ERROR_FLAG into x_DP_BUILD_ERROR_FLAG
                from msd_demand_plans
                where demand_plan_id = MSD_COMMON_UTILITIES_LB.get_demand_plan_id(p_plan_id) ;
Line: 680

		Delete_duplicate(p_plan_id ,  MSD_COMMON_UTILITIES_LB.LEVEL_VALUES_STAGING_TABLE);
Line: 681

                                Delete_duplicate_lvl_assoc(errbuf, retcode, p_plan_id);
Line: 706

    SELECT  DISTINCT dp_dimension_code,
            hl.hierarchy_name,
            hl.level_name,
            hl.relationship_view
    FROM    msd_dp_hierarchies dh,
                   msd_hierarchy_levels_lb_v hl
    WHERE   demand_plan_id = p_demand_plan_id
    AND	    dp_dimension_code <> 'TIM'
    AND     dh.hierarchy_id = hl.hierarchy_id
    AND     level_id NOT IN
	        (select distinct level_id
        	 from   msd_level_values_lb lv
        	 where lv.plan_id = p_plan_id
        	 );
Line: 726

     SELECT calendar_type, calendar_code, decode(calendar_type,
                                                1, initcap(calendar_code),
                                                calendar_code) op_cal_code
      FROM msd_dp_calendars
      WHERE demand_plan_id = p_demand_plan_id
      and calendar_type <> 1; -- To Prevent the validation of Gregorian  calendar  because validation of Gregorian Calendar is not required
Line: 737

      SELECT
      min(start_date), max(end_date)
      FROM msd_dp_parameters_cs_v
      WHERE demand_plan_id = p_demand_plan_id;
Line: 746

      SELECT MIN(day) min_date, MAX(day) max_date
       FROM msd_time_lb_v dp
       WHERE dp.calendar_type = p_calendar_type
       AND dp.calendar_code = p_calendar_code ;
Line: 755

        SELECT
        distinct
        mdp.parameter_type ,
        mcd.planning_server_view_name ,
        mcd.description
        FROM   msd_dp_parameters mdp , msd_cs_definitions mcd
        where mdp.demand_plan_id =p_demand_plan_id
        and parameter_type =mcd.name
        and nvl(  mcd.planning_server_view_name, 'NA')  <> 'NA'
        and nvl(mcd.liability_user_flag , 'N') <> 'Y' ;
Line: 850

                        v_sql_stmt := 'select count(1) from dual where exists (select 1 from  '
                                                 ||x_input_param_rec.planning_server_view_name
                                                 ||'  where cs_name =  '
                                                 ||''''||x_plan_name||''''||' ) ' ;
Line: 986

	       p_update_lvl_table  IN  NUMBER) IS

x_source_table  VARCHAR2(50) ;
Line: 992

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

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 = 'LIABILITY';
Line: 1039

	      SELECT hierarchy_name INTO p_hierarchy_name
	      FROM   msd_hierarchies
	      WHERE  hierarchy_id = Relationship_Rec.hierarchy_id;
Line: 1070

	        p_update_lvl_table         => p_update_lvl_table,
	        p_delete_flag              => x_delete_flag,
                        p_seq_num                  => p_seq_num);
Line: 1111

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

select distinct level_id, level_type_code
from msd_hierarchy_levels_lb_v
where owning_dimension_code = p_dimension_code
order by level_type_code, level_id;
Line: 1141

		p_update_lvl_table => 0);
Line: 1150

		p_update_lvl_table => 1);
Line: 1182

select lookup_code
from fnd_lookup_values_vl
where lookup_type = 'MSD_DIMENSIONS_LB' ;
Line: 1208

              /*  delete duplicate data */
                Delete_duplicate(p_plan_id, MSD_COMMON_UTILITIES_LB.LEVEL_VALUES_STAGING_TABLE);
Line: 1211

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

Procedure  Delete_duplicate(p_plan_id in number, p_dest_table in varchar2) is
Begin

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

   if p_dest_table = MSD_COMMON_UTILITIES_LB.LEVEL_VALUES_STAGING_TABLE then
    delete from msd_st_level_values_lb a where
    a.plan_id = p_plan_id and
    rowid <> (select max(rowid) from msd_st_level_values_lb b
              where  a.plan_id = b.plan_id and a.level_id = b.level_id and a.sr_level_pk = b.sr_level_pk);
Line: 1245

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

cursor c_duplicate is
select  level_id, sr_level_pk, parent_level_id
from msd_st_level_associations_lb
where  plan_id = p_plan_id
group by level_id, sr_level_pk, parent_level_id
having count(*) > 1;
Line: 1266

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

     OPEN  c_duplicate;
Line: 1276

           delete from msd_st_level_associations_lb a where
           a.plan_id = p_plan_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_lb b
                     where b.plan_id = p_plan_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: 1299

END Delete_duplicate_lvl_assoc;
Line: 1316

                        p_update_lvl_table                          IN  NUMBER,
                        p_delete_flag                                   IN  VARCHAR2,
                        p_seq_num                                     IN  NUMBER ) IS

v_plan_id    varchar2(40);
Line: 1336

v_up := p_update_lvl_table;
Line: 1341

   Savepoint Before_Delete ;
Line: 1351

         IF (p_update_lvl_table = 1) THEN
             /* Insert deleted level values into deleted_level_value table and delete it
                from the fact level value table */
             /* For Incremental Level Value Collection, p_delete_flag = 'N'
                So, we don't delete existing level values */

             /* Process row by row from staging level values table */
         --   fnd_file.put_line(fnd_file.log,'3:translate Level Values ' );
Line: 1383

         /* Delete Staging Table only if delete flag = Yes */
         IF (p_delete_flag = 'Y') THEN
              /* First time to process this level_id */
              IF (p_update_lvl_table = 1) THEN
                   DELETE FROM msd_st_level_values_lb
                   WHERE plan_id = p_plan_id AND level_id = p_level_id;
Line: 1392

              DELETE FROM msd_st_level_associations_lb
              WHERE plan_id = p_plan_id AND
                    level_id = p_level_id
                AND parent_level_id = p_parent_level_id;
Line: 1399

         /* Insert Level Values into staging table */
	 v_sql_stmt :=  'insert  /*+ ALL_ROWS */ into ' || p_dest_table || ' ( '
	              	||'plan_id, ' ||
                        'level_id, ' ||
                        'level_value, ' ||
                        'sr_level_pk, ' ||
                        'level_value_desc, ' ||
                        'last_update_date, ' ||
                        'last_updated_by, ' ||
                        'creation_date, ' ||
                        'created_by ) ' ||
                        'select   ' ||
                         p_plan_id ||', ' ||
                         p_level_id || ', ' ||
                         p_level_value_column||', ' ||
                         p_level_value_pk_column||', ' ||
                         p_level_value_desc_column||', ' ||
                         'sysdate, ' ||
                        FND_GLOBAL.USER_ID || ', ' ||
                        'sysdate, ' ||
                        FND_GLOBAL.USER_ID || ' ' ||
                        'from ' ||
                        p_source_table||
                        ' where '||
                        'plan_id = '||
                        p_plan_id ;
Line: 1433

         /* Insert Level Associations into  staging table */
         v_sql_stmt :=  'insert  /*+ ALL_ROWS */ into ' || v_dest_ass_table || ' ( ' ||
                                'plan_id, ' ||
                                'level_id, ' ||
                                'sr_level_pk, ' ||
                                'parent_level_id, ' ||
                                'sr_parent_level_pk, ' ||
                                'last_update_date, ' ||
                                'last_updated_by, ' ||
                                'creation_date, ' ||
                                'created_by ) ' ||
                                'select   ' ||
                                p_plan_id||', ' ||
                                p_level_id || ', ' ||
                                p_level_value_pk_column||', ' ||
                                p_parent_level_id || ', ' ||
                                p_parent_value_pk_column ||', ' ||
                                'sysdate, ' ||
                                FND_GLOBAL.USER_ID || ', ' ||
                                'sysdate, ' ||
                                FND_GLOBAL.USER_ID || ' ' ||
                                ' from ' ||
                                p_source_table||
                                ' where '||
                                'plan_id = '||
                                p_plan_id ;
Line: 1469

         select level_type_code into v_parent_lvl_type
         from   msd_levels
         where  level_id = p_parent_level_id
         and plan_type  =  'LIABILITY' ;
Line: 1489

   IF (v_parent_lvl_type = '1' AND p_update_lvl_table = 1) THEN

--fnd_file.put_line(fnd_file.log,'1: Before PROCESS_TOP_LEVEL_VALUES ');
Line: 1503

                        p_delete_flag);
Line: 1536

/* New Level values will be inserted into fact table
   and will get deleted from the staging */
CURSOR c_insert IS
select sr_level_pk
from msd_st_level_values_lb
where plan_id = p_plan_id and level_id = p_level_id
MINUS
select sr_level_pk
from msd_level_values_lb
where plan_id = p_plan_id and level_id = p_level_id;
Line: 1549

   new level values are deleted from the staging table
*/
CURSOR c_update IS
(select sr_level_pk, level_value,
level_value_desc
from msd_st_level_values_lb
where plan_id = p_plan_id and level_id = p_level_id
MINUS
select sr_level_pk, level_value,
level_value_desc
from msd_level_values_lb
where plan_id = p_plan_id and level_id = p_level_id);
Line: 1576

   OPEN  c_insert;
Line: 1577

   FETCH c_insert BULK COLLECT INTO a_sr_level_pk;
Line: 1578

   CLOSE c_insert;
Line: 1581

      /* First Delete fetched rows from staging, and then
         Insert them into Fact Table.
      */
   ---fnd_file.put_line(fnd_file.log,'**In 2 PROCESS_LEVEL_VALUE_PER_ROW********');
Line: 1586

        DELETE FROM msd_st_level_values_lb
        WHERE plan_id = p_plan_id and
              level_id = p_level_id and
              sr_level_pk = a_sr_level_pk(i)
        RETURNING level_value, level_value_desc
        BULK COLLECT INTO a_level_value,
                          a_level_value_desc;
Line: 1606

      /* Insert new rows into fact table */
      FORALL j IN a_sr_level_pk.FIRST..a_sr_level_pk.LAST


         INSERT INTO msd_level_values_lb(
                                     plan_id, level_id, level_value,
                                     sr_level_pk, level_pk, level_value_desc,
                                     action_code, created_by_refresh_num,  last_refresh_num,
                                     last_update_date, last_updated_by,
                                     creation_date, created_by,
                                     last_update_login)
         VALUES(
                   p_plan_id,
                    p_level_id,
                    a_level_value(j),
                    a_sr_level_pk(j),
                    a_level_pk(j),
                    a_level_value_desc(j),
                   'I', p_seq_num, p_seq_num,
                    sysdate, FND_GLOBAL.USER_ID,
                    sysdate, FND_GLOBAL.USER_ID,
                    FND_GLOBAL.LOGIN_ID );
Line: 1631

  /* Fetch updated rows from staging */
   OPEN  c_update;
Line: 1633

   FETCH c_update BULK COLLECT INTO a_sr_level_pk, a_level_value,
                                    a_level_value_desc;
Line: 1635

   CLOSE c_update;
Line: 1639

         UPDATE msd_level_values_lb
         SET level_value = a_level_value(i),
             level_value_desc = a_level_value_desc(i),
             action_code = 'U',
             last_refresh_num = p_seq_num,
             last_update_date = sysdate
         WHERE plan_id = p_plan_id and
               level_id = p_level_id and
               sr_level_pk = a_sr_level_pk(i);
Line: 1679

/* This cursur will select only new level associations */
CURSOR c_new_rows IS
(select sr_level_pk
from msd_st_level_associations_lb
where plan_id = p_plan_id and level_id = p_level_id and
parent_level_id = p_parent_level_id
MINUS
select sr_level_pk
from msd_level_associations_lb
where plan_id = p_plan_id and level_id = p_level_id and
      parent_level_id = p_parent_level_id);
Line: 1692

/* Cursor for updated level association */
/* This cursor need to be opened only after
   new associations are deleted from the staging table */
CURSOR c_update_rows IS
(select sr_level_pk, sr_parent_level_pk
from msd_st_level_associations_lb
where plan_id = p_plan_id and level_id = p_level_id and
parent_level_id = p_parent_level_id
MINUS
select sr_level_pk, sr_parent_level_pk
from msd_level_associations_lb
where plan_id = p_plan_id and level_id = p_level_id and
      parent_level_id = p_parent_level_id);
Line: 1723

        /* First Delete fetched rows(new level associations) from staging,
           and then Insert them into Fact Table.
        */
        FORALL i IN a_sr_level_pk.FIRST..a_sr_level_pk.LAST
           DELETE FROM msd_st_level_associations_lb
           WHERE plan_id = p_plan_id and
                 level_id = p_level_id and
                 sr_level_pk = a_sr_level_pk(i) and
                 parent_level_id = p_parent_level_id
           RETURNING sr_parent_level_pk
           BULK COLLECT INTO a_sr_parent_level_pk;
Line: 1735

        /* Insert new rows into fact table */
        IF (a_sr_parent_level_pk.exists(1)) THEN
           FORALL i IN a_sr_level_pk.FIRST..a_sr_level_pk.LAST
              INSERT INTO msd_level_associations_lb(
                          plan_id, level_id, sr_level_pk,
                          parent_level_id, sr_parent_level_pk,
                          last_update_date, last_updated_by,
                          creation_date, created_by, last_update_login,
                          created_by_refresh_num, last_refresh_num, action_code)
              VALUES(  p_plan_id, p_level_id, a_sr_level_pk(i),
                     p_parent_level_id, a_sr_parent_level_pk(i),
                     sysdate, FND_GLOBAL.USER_ID,
                     sysdate,FND_GLOBAL.USER_ID, FND_GLOBAL.LOGIN_ID,
                     p_seq_num, p_seq_num, 'I');
Line: 1752

     OPEN  c_update_rows;
Line: 1753

     FETCH c_update_rows BULK COLLECT INTO a_sr_level_pk, a_sr_parent_level_pk;
Line: 1754

     CLOSE c_update_rows;
Line: 1756

     /* For updated level association */
     IF (a_sr_level_pk.exists(1) and a_sr_parent_level_pk.exists(1)) THEN
        FORALL i IN a_sr_level_pk.FIRST..a_sr_level_pk.LAST
            UPDATE msd_level_associations_lb
            SET
               sr_parent_level_pk = a_sr_parent_level_pk(i),
               action_code = 'U',
               last_refresh_num = p_seq_num,
               last_update_date = sysdate
            WHERE plan_id = p_plan_id and
                  level_id = p_level_id and
                  sr_level_pk = a_sr_level_pk(i) and
                  parent_level_id = p_parent_level_id;
Line: 1799

                        p_delete_flag                   IN  VARCHAR2) IS


v_sql_stmt       varchar2(4000);
Line: 1822

                delete from msd_st_level_values_lb
                where plan_id = p_plan_id
                      and level_id = p_parent_level_id ;
Line: 1827

             v_sql_stmt :=  'insert  /*+ ALL_ROWS */ into ' || p_dest_table || ' ( ' ||
                       'plan_id, ' ||
                       'level_value, ' ||
                       'sr_level_pk, ' ||
                       'level_id, ' ||
                       'level_value_desc, ' ||
                       'last_update_date, ' ||
                       'last_updated_by, ' ||
                       'creation_date, ' ||
                       'created_by ) ' ||
                       'SELECT ''' ||
                        p_plan_id ||''', ' ||
                        p_parent_value_column || ', ' ||
                        p_parent_value_pk_column ||', '  ||
                        p_parent_level_id || ', ' ||
                       'parent_desc_alias' ||', ' ||
                       'sysdate, ' || FND_GLOBAL.USER_ID || ', ' ||
                       'sysdate, ' || FND_GLOBAL.USER_ID || ' ' ||
                       'FROM ' ||
                       '(select distinct ' || p_parent_value_column || ', ' ||
                       p_parent_value_pk_column || ', ' ||
                       p_parent_level_id || ', '||
                       p_parent_value_desc_column || ' parent_desc_alias ' || ' from ' ||
                       p_source_table||' where plan_id = '||p_plan_id|| ') src ';
Line: 1885

x_delete_flag   VARCHAR2(1);
Line: 1889

select  distinct
	mla.plan_id,
                ml.level_type_code,
	mla.level_id,
	mla.parent_level_id
from     msd_st_level_associations_lb mla, msd_levels ml
where   mla.level_id = ml.level_id
      and ml.plan_type = 'LIABILITY'
      and mla.plan_id = p_plan_id ;
Line: 1903

            x_delete_flag := 'N';
Line: 1909

        /*   Fetch new seq number for deleted level values */
        SELECT msd.msd_last_refresh_number_s.nextval
        INTO l_seq_num from dual;
Line: 1935

			p_update_lvl_table	=> 0,

                        p_delete_flag           => x_delete_flag,
                        p_seq_num               => l_seq_num
 			) ;
Line: 1949

			Delete from msd_st_level_associations_lb
			where   plan_id = Relationship_Rec.plan_id
                        and     level_id = Relationship_Rec.level_id
                        and     parent_level_id = Relationship_Rec.parent_level_id ;
Line: 1974

	        p_update_lvl_table	=> 1,
                        p_delete_flag           => x_delete_flag,
                        p_seq_num               => l_seq_num
 			) ;
Line: 1988

			Delete 	from msd_st_level_values_lb
			where  	plan_id = Relationship_Rec.plan_id
			and	level_id = Relationship_Rec.level_id ;
Line: 1992

			Delete from msd_st_level_associations_lb
			where   plan_id = Relationship_Rec.plan_id
                        and     level_id = Relationship_Rec.level_id
                        and     parent_level_id = Relationship_Rec.parent_level_id ;
Line: 2009

	Delete 	from msd_st_level_values_lb
	where  	level_id in (
		select level_id
		from msd_levels
		where level_type_code = '1'
		and plan_type = 'LIABILITY') ;
Line: 2035

  SELECT demand_plan_name
  FROM msd_demand_plans
  WHERE demand_plan_id = p_demand_plan_id
  FOR UPDATE of demand_plan_name NOWAIT;
Line: 2075

      select
      plan_id plan_id
     from msd_level_values_lb
     minus
     Select
     liab_plan_id plan_id
     from msd_demand_plans ;
Line: 2097

     Delete from msd_level_values_lb where plan_id = to_number (a_plan_id(i) );
Line: 2099

     Delete from msd_level_associations_lb where plan_id =  to_number (a_plan_id(i) );
Line: 2138

	select
	count(*) no_of_agreements
	from
	msc_item_suppliers mis ,
	MSC_ASL_AUTH_DETAILS maad
	where
	maad.sr_instance_id = mis.sr_instance_id
	and maad.organization_id = mis.organization_id
	and maad.supplier_id = mis.supplier_id
	and maad.inventory_item_id = mis.inventory_item_id
	and mis.plan_id = p_plan_id
	and maad.plan_id = -1  ;
Line: 2199

      update msd_demand_plans set base_uom = x_base_uom where liab_plan_id = p_plan_id ;
Line: 2208

          update  msd_demand_plans set valid_flag = 1  where liab_plan_id = p_plan_id ;
Line: 2232

    SELECT scen.scenario_name,ml.dimension_code,count(*)
    FROM
	msd_dp_scenario_output_levels a,
	msd_levels ml,
	msd_dp_scenarios scen,
	msd_demand_plans mdp
    WHERE  a.level_id = ml.level_id
    AND    a.scenario_id = scen.scenario_id
    AND    scen.enable_flag = 'Y'
	and scen.demand_plan_id = mdp.demand_plan_id
	and a.demand_plan_id = mdp.demand_plan_id
	and mdp.liab_plan_id = p_plan_id
	and ml.plan_type = 'LIABILITY'
	group by scen.scenario_name,ml.dimension_code
	having count(*) >1  ;
Line: 2252

     select m_min_tim_lvl_id from
     msd_demand_plans mdp
     where
      mdp.liab_plan_id =p_plan_id   ;
Line: 2260

      select  mdc.calendar_type
      from
      msd_dp_calendars mdc ,
      msd_demand_plans mdp
      where
      mdc.demand_plan_id = mdp.demand_plan_id
      and mdp.liab_plan_id = p_plan_id
      and mdc.calendar_type = 2 ;
Line: 2288

      display_message('Scenario '||get_dup_dim_output_levels_rec.scenario_name||' has more than one Output  Level selected  ' , ERROR) ;
Line: 2328

 delete from  msd_time_lb  where CALENDAR_CODE in
( select CALENDAR_CODE from msd_dp_calendars where demand_plan_id =  p_demand_plan_id)
 ;
Line: 2334

 insert into msd_time_lb (
  CALENDAR_TYPE,
  CALENDAR_CODE,
  SEQ_NUM,
  YEAR,
  YEAR_DESCRIPTION,
  YEAR_START_DATE,
  YEAR_END_DATE,
  QUARTER,
  QUARTER_DESCRIPTION,
  QUARTER_START_DATE,
  QUARTER_END_DATE,
  MONTH,
  MONTH_DESCRIPTION,
  MONTH_START_DATE,
  MONTH_END_DATE,
  WEEK,
  WEEK_DESCRIPTION,
  WEEK_START_DATE,
  WEEK_END_DATE,
  DAY,
  DAY_DESCRIPTION,
  WORKING_DAY )
select * from msd_sr_time_lb_v
where  CALENDAR_CODE
 in ( select CALENDAR_CODE from msd_dp_calendars where demand_plan_id = p_demand_plan_id and calendar_type <> 1 )  ;