1: PACKAGE BODY MSC_UTIL AS
2: /* $Header: MSCUTILB.pls 120.45 2012/06/05 12:22:00 lsindhur ship $ */
3:
4: -- GLOBAL VARIABLES IN BODY
5: APPS_SCHEMA VARCHAR2(30);
8:
9: v_deprecatedMVList TblNmTblTyp:=
10: TblNmTblTyp( 'BOM_CTO_ORDER_DMD_SN');
11: v_deprecatedMVSchemaList TblNmTblTyp:=
12: TblNmTblTyp( msc_util.G_BOM_SCHEMA );
13:
14: FUNCTION Check_MSG_Level(pType IN NUMBER) RETURN BOOLEAN
15: IS
16: BEGIN
221: IF Check_MSG_Level(G_LVL_STATUS) THEN
222: Print_Msg('************************************************************');
223: Print_Msg('Parameters selected for planning data pull:');
224: Print_Msg('------------------------------------------------------------');
225: IF pRECALC_SH = MSC_UTIL.SYS_YES THEN
226: Print_Msg('Recalculate Sourcing History: YES ' );
227: ELSE
228: Print_Msg('Recalculate Sourcing History: NO ' );
229: END IF;
226: Print_Msg('Recalculate Sourcing History: YES ' );
227: ELSE
228: Print_Msg('Recalculate Sourcing History: NO ' );
229: END IF;
230: IF pPURGE_SH = MSC_UTIL.SYS_YES THEN
231: Print_Msg('Purge Sourcing History : YES ' );
232: ELSE
233: Print_Msg('Purge Sourcing History : NO ' );
234: END IF;
343:
344: PROCEDURE compare_index(
345: p_table_name IN VARCHAR2,
346: p_index_name IN VARCHAR2,
347: p_column_list IN MSC_UTIL.char30_arr,
348: x_create_index OUT NOCOPY BOOLEAN,
349: x_partitioned OUT NOCOPY BOOLEAN
350: )
351: IS
419: IF c_ind_columns%ISOPEN THEN
420: CLOSE c_ind_columns;
421: END IF;
422: ---- bug 2234098 change error code from 21001 to 20001
423: RAISE_APPLICATION_ERROR(-20001, 'MSC_UTIL.COMPARE_INDEX: Error while checking the index attributes: ' || SQLERRM);
424: END compare_index;
425:
426:
427:
432: IS
433: v_sql_stmt VARCHAR2(6000);
434: BEGIN
435:
436: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Creating Snapshot Log for ' ||p_table||' ...');
437:
438: v_sql_stmt:=
439: ' CREATE SNAPSHOT LOG ON '||p_schema ||'.'||p_table||' WITH ROWID ' ;
440:
443: statement_type => AD_DDL.CREATE_TABLE,
444: statement => v_sql_stmt,
445: object_name => p_table);
446:
447: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Snapshot Log for ' ||p_table||' successfully created...');
448:
449: EXCEPTION
450: WHEN OTHERS THEN
451:
450: WHEN OTHERS THEN
451:
452: IF SQLCODE IN (-12000) THEN
453: /*Snapshot Log already EXISTS*/
454: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Snapshot Log on ' ||p_table||' already exists...');
455:
456: ELSIF SQLCODE IN (-00942) THEN
457: /*Base Table does not exist*/
458: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Table '||p_table||' does not exist...');
454: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Snapshot Log on ' ||p_table||' already exists...');
455:
456: ELSIF SQLCODE IN (-00942) THEN
457: /*Base Table does not exist*/
458: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Table '||p_table||' does not exist...');
459: ELSE
460: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, SQLERRM);
461: RAISE_APPLICATION_ERROR(-20001, 'Snapshot Log Creation on '|| p_table||' failed : ' || sqlerrm);
462: END IF;
456: ELSIF SQLCODE IN (-00942) THEN
457: /*Base Table does not exist*/
458: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Table '||p_table||' does not exist...');
459: ELSE
460: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, SQLERRM);
461: RAISE_APPLICATION_ERROR(-20001, 'Snapshot Log Creation on '|| p_table||' failed : ' || sqlerrm);
462: END IF;
463: END CREATE_SNAP_LOG; --create_snap Log
464: /* ======== Create Snap Log========== */
472: v_sql_stmt VARCHAR2(6000);
473: lappshortname VARCHAR2(30);
474: BEGIN
475:
476: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Creating Snapshot Log for ' ||p_table||' ...');
477:
478: SELECT application_short_name
479: into lappshortname
480: FROM fnd_application
488: statement_type => AD_DDL.CREATE_TABLE,
489: statement => v_sql_stmt,
490: object_name => p_table);
491:
492: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Snapshot Log for ' ||p_table||' successfully created...');
493:
494: EXCEPTION
495: WHEN OTHERS THEN
496:
495: WHEN OTHERS THEN
496:
497: IF SQLCODE IN (-12000) THEN
498: /*Snapshot Log already EXISTS*/
499: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Snapshot Log on ' ||p_table||' already exists...');
500:
501: ELSIF SQLCODE IN (-00942) THEN
502: /*Base Table does not exist*/
503: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Table '||p_table||' does not exist...');
499: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Snapshot Log on ' ||p_table||' already exists...');
500:
501: ELSIF SQLCODE IN (-00942) THEN
502: /*Base Table does not exist*/
503: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Table '||p_table||' does not exist...');
504: ELSE
505: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, SQLERRM);
506: RAISE_APPLICATION_ERROR(-20001, 'Snapshot Log Creation on '|| p_table||' failed : ' || sqlerrm);
507: END IF;
501: ELSIF SQLCODE IN (-00942) THEN
502: /*Base Table does not exist*/
503: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Table '||p_table||' does not exist...');
504: ELSE
505: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, SQLERRM);
506: RAISE_APPLICATION_ERROR(-20001, 'Snapshot Log Creation on '|| p_table||' failed : ' || sqlerrm);
507: END IF;
508: END CREATE_SNAP_LOG; --create_snap Log
509: /* ======== Overloading Create Snap Log========== */
597: END IF;
598:
599: EXCEPTION
600: WHEN OTHERS THEN
601: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, SQLERRM);
602: raise_application_error(-20001, 'Error in Getting Storage Parameters : ' || sqlerrm);
603: END GET_STORAGE_PARAMETERS;
604:
605:
624:
625: v_logging_stmt := 'ALTER MATERIALIZED VIEW '||p_schema||'.'||p_object
626: ||' '||p_logging ||' PARALLEL '|| p_parallel_degree;
627:
628: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Creating Snapshot for '||p_table||' ...');
629:
630:
631: SELECT application_short_name
632: INTO lv_appl_short_nm
632: INTO lv_appl_short_nm
633: FROM fnd_application
634: WHERE application_id=724;
635:
636: IF p_schema = MSC_UTIL.G_APPS_SCHEMA THEN
637:
638: EXECUTE IMMEDIATE p_sql_stmt;
639:
640: ELSE
645: statement => p_sql_stmt,
646: object_name => p_object);
647: END IF;
648:
649: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Snapshot for '||p_table||' succesfully created...');
650:
651: FND_STATS.gather_table_stats(p_schema,p_object,lv_pctg, lv_deg);
652:
653: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Gathered Statistics for the Snapshot '||p_object||' succesfully ...');
649: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Snapshot for '||p_table||' succesfully created...');
650:
651: FND_STATS.gather_table_stats(p_schema,p_object,lv_pctg, lv_deg);
652:
653: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Gathered Statistics for the Snapshot '||p_object||' succesfully ...');
654:
655: EXECUTE IMMEDIATE v_logging_stmt;
656: MSC_UTIL.LOG_MSG(MSC_UTIL.G_D_DEBUG_1, 'Altering Snapshot : '||p_object);
657:
652:
653: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Gathered Statistics for the Snapshot '||p_object||' succesfully ...');
654:
655: EXECUTE IMMEDIATE v_logging_stmt;
656: MSC_UTIL.LOG_MSG(MSC_UTIL.G_D_DEBUG_1, 'Altering Snapshot : '||p_object);
657:
658:
659: RETURN TRUE;
660:
661: EXCEPTION
662: WHEN OTHERS THEN
663: IF SQLCODE IN (-12006) THEN
664: /*Snapshot already EXISTS*/
665: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Snapshot on '||p_table||' already exists...');
666: EXECUTE IMMEDIATE v_logging_stmt;
667: MSC_UTIL.LOG_MSG(MSC_UTIL.G_D_DEBUG_1, 'Altering Snapshot : '||p_object);
668: RETURN TRUE;
669: ELSIF SQLCODE IN (-01749) THEN
663: IF SQLCODE IN (-12006) THEN
664: /*Snapshot already EXISTS*/
665: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Snapshot on '||p_table||' already exists...');
666: EXECUTE IMMEDIATE v_logging_stmt;
667: MSC_UTIL.LOG_MSG(MSC_UTIL.G_D_DEBUG_1, 'Altering Snapshot : '||p_object);
668: RETURN TRUE;
669: ELSIF SQLCODE IN (-01749) THEN
670: /*you may not GRANT/REVOKE privileges to/from yourself*/
671: /* snapshot created in apps schema*/
670: /*you may not GRANT/REVOKE privileges to/from yourself*/
671: /* snapshot created in apps schema*/
672: RETURN TRUE;
673: ELSIF instr(p_error,','||trim(SQLCODE)||',')>0 THEN /*6501625*/
674: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, sqlerrm);
675: RETURN FALSE;
676: ELSE
677: -- no need to log the error message twice, hence commenting.
678: -- The following error will be logged in the place from where create_snap is called.
675: RETURN FALSE;
676: ELSE
677: -- no need to log the error message twice, hence commenting.
678: -- The following error will be logged in the place from where create_snap is called.
679: --MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, SQLERRM);
680: RAISE_APPLICATION_ERROR(-20001, 'Snapshot Creation on '|| p_table||' failed : ' || sqlerrm);
681: END IF;
682:
683: END CREATE_SNAP ; --Snapshot
707:
708: v_logging_stmt := 'ALTER MATERIALIZED VIEW '||p_schema||'.'||p_object
709: ||' '||p_logging ||' PARALLEL '|| p_parallel_degree;
710:
711: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Creating Snapshot for '||p_table||' ...');
712:
713: SELECT application_short_name
714: INTO lv_appl_short_nm
715: FROM fnd_application
714: INTO lv_appl_short_nm
715: FROM fnd_application
716: WHERE application_id=724;
717:
718: IF p_schema = MSC_UTIL.G_APPS_SCHEMA THEN
719: return CREATE_SNAP2_AS( p_table,
720: p_object,
721: p_sql_stmt,
722: p_logging,
730: statement => p_sql_stmt,
731: object_name => p_object);
732: END IF;
733:
734: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Snapshot for '||p_table||' succesfully created...');
735:
736: FND_STATS.gather_table_stats(p_schema,p_object,lv_pctg, lv_deg);
737:
738: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Gathered Statistics for the Snapshot '||p_object||' succesfully ...');
734: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Snapshot for '||p_table||' succesfully created...');
735:
736: FND_STATS.gather_table_stats(p_schema,p_object,lv_pctg, lv_deg);
737:
738: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Gathered Statistics for the Snapshot '||p_object||' succesfully ...');
739:
740: EXECUTE IMMEDIATE v_logging_stmt;
741: MSC_UTIL.LOG_MSG(MSC_UTIL.G_D_DEBUG_1, 'Altering Snapshot : '||p_object);
742:
737:
738: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Gathered Statistics for the Snapshot '||p_object||' succesfully ...');
739:
740: EXECUTE IMMEDIATE v_logging_stmt;
741: MSC_UTIL.LOG_MSG(MSC_UTIL.G_D_DEBUG_1, 'Altering Snapshot : '||p_object);
742:
743:
744: RETURN TRUE;
745:
746: EXCEPTION
747: WHEN OTHERS THEN
748: IF SQLCODE IN (-12006) THEN
749: /*Snapshot already EXISTS*/
750: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Snapshot on '||p_table||' already exists...');
751: EXECUTE IMMEDIATE v_logging_stmt;
752: MSC_UTIL.LOG_MSG(MSC_UTIL.G_D_DEBUG_1, 'Altering Snapshot : '||p_object);
753: RETURN TRUE;
754: ELSIF SQLCODE IN (-01749) THEN
748: IF SQLCODE IN (-12006) THEN
749: /*Snapshot already EXISTS*/
750: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Snapshot on '||p_table||' already exists...');
751: EXECUTE IMMEDIATE v_logging_stmt;
752: MSC_UTIL.LOG_MSG(MSC_UTIL.G_D_DEBUG_1, 'Altering Snapshot : '||p_object);
753: RETURN TRUE;
754: ELSIF SQLCODE IN (-01749) THEN
755: /*you may not GRANT/REVOKE privileges to/from yourself*/
756: /* snapshot created in apps schema*/
755: /*you may not GRANT/REVOKE privileges to/from yourself*/
756: /* snapshot created in apps schema*/
757: RETURN TRUE;
758: ELSIF instr(p_error,','||trim(SQLCODE)||',')>0 THEN /*6501625*/
759: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, sqlerrm);
760: RETURN FALSE;
761: ELSE
762: -- no need to log the error message twice, hence commenting.
763: -- The following error will be logged in the place from where create_snap is called.
760: RETURN FALSE;
761: ELSE
762: -- no need to log the error message twice, hence commenting.
763: -- The following error will be logged in the place from where create_snap is called.
764: --MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, SQLERRM);
765: RAISE_APPLICATION_ERROR(-20001, 'Snapshot Creation on '|| p_table||' failed : ' || sqlerrm);
766: END IF;
767:
768: END CREATE_SNAP2 ; --Snapshot
785:
786:
787: BEGIN -- Snapshot
788:
789: v_logging_stmt := 'ALTER MATERIALIZED VIEW '||MSC_UTIL.G_APPS_SCHEMA||'.'||p_object
790: ||' '||p_logging ||' PARALLEL '|| p_parallel_degree;
791:
792: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Creating Snapshot for '||p_table||' ...');
793:
788:
789: v_logging_stmt := 'ALTER MATERIALIZED VIEW '||MSC_UTIL.G_APPS_SCHEMA||'.'||p_object
790: ||' '||p_logging ||' PARALLEL '|| p_parallel_degree;
791:
792: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Creating Snapshot for '||p_table||' ...');
793:
794: ad_mv.do_mv_ddl(
795: an_operation_i => ad_mv.mv_create,
796: as_mview_name_i => p_object,
797: as_stmt_i => p_sql_stmt,
798: ab_execute_i => TRUE
799: );
800:
801: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Snapshot for '||p_table||' succesfully created...');
802:
803: FND_STATS.gather_table_stats(MSC_UTIL.G_APPS_SCHEMA,p_object,lv_pctg, lv_deg);
804:
805: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Gathered Statistics for the Snapshot '||p_object||' succesfully ...');
799: );
800:
801: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Snapshot for '||p_table||' succesfully created...');
802:
803: FND_STATS.gather_table_stats(MSC_UTIL.G_APPS_SCHEMA,p_object,lv_pctg, lv_deg);
804:
805: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Gathered Statistics for the Snapshot '||p_object||' succesfully ...');
806:
807: EXECUTE IMMEDIATE v_logging_stmt;
801: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Snapshot for '||p_table||' succesfully created...');
802:
803: FND_STATS.gather_table_stats(MSC_UTIL.G_APPS_SCHEMA,p_object,lv_pctg, lv_deg);
804:
805: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Gathered Statistics for the Snapshot '||p_object||' succesfully ...');
806:
807: EXECUTE IMMEDIATE v_logging_stmt;
808: MSC_UTIL.LOG_MSG(MSC_UTIL.G_D_DEBUG_1, 'Altering Snapshot : '||p_object);
809:
804:
805: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Gathered Statistics for the Snapshot '||p_object||' succesfully ...');
806:
807: EXECUTE IMMEDIATE v_logging_stmt;
808: MSC_UTIL.LOG_MSG(MSC_UTIL.G_D_DEBUG_1, 'Altering Snapshot : '||p_object);
809:
810:
811: RETURN TRUE;
812:
813: EXCEPTION
814: WHEN OTHERS THEN
815: IF SQLCODE IN (-12006) THEN
816: /*Snapshot already EXISTS*/
817: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Snapshot on '||p_table||' already exists...');
818: EXECUTE IMMEDIATE v_logging_stmt;
819: MSC_UTIL.LOG_MSG(MSC_UTIL.G_D_DEBUG_1, 'Altering Snapshot : '||p_object);
820: RETURN TRUE;
821: ELSIF SQLCODE IN (-01749) THEN
815: IF SQLCODE IN (-12006) THEN
816: /*Snapshot already EXISTS*/
817: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Snapshot on '||p_table||' already exists...');
818: EXECUTE IMMEDIATE v_logging_stmt;
819: MSC_UTIL.LOG_MSG(MSC_UTIL.G_D_DEBUG_1, 'Altering Snapshot : '||p_object);
820: RETURN TRUE;
821: ELSIF SQLCODE IN (-01749) THEN
822: /*you may not GRANT/REVOKE privileges to/from yourself*/
823: /* snapshot created in apps schema*/
822: /*you may not GRANT/REVOKE privileges to/from yourself*/
823: /* snapshot created in apps schema*/
824: RETURN TRUE;
825: ELSIF instr(p_error,','||trim(SQLCODE)||',')>0 THEN /*6501625*/
826: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, sqlerrm);
827: RETURN FALSE;
828: ELSE
829: -- no need to log the error message twice, hence commenting.
830: -- The following error will be logged in the place from where create_snap is called.
827: RETURN FALSE;
828: ELSE
829: -- no need to log the error message twice, hence commenting.
830: -- The following error will be logged in the place from where create_snap is called.
831: --MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, SQLERRM);
832: RAISE_APPLICATION_ERROR(-20001, 'Snapshot Creation on '|| p_table||' failed : ' || sqlerrm);
833: END IF;
834:
835: END CREATE_SNAP2_AS ; --Snapshot
853: INTO lv_appl_short_nm
854: FROM fnd_application
855: WHERE application_id=724;
856:
857: IF p_schema = MSC_UTIL.G_APPS_SCHEMA THEN
858:
859: EXECUTE IMMEDIATE p_sql_stmt;
860:
861: ELSE
866: statement => p_sql_stmt,
867: object_name => p_object);
868: END IF;
869:
870: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Index '||p_object||' succesfully created...');
871:
872: EXCEPTION
873: WHEN OTHERS THEN
874: IF SQLCODE IN (-01408) THEN
878: SQLCODE IN (-00955) THEN
879: /*Index already exists*/
880: NULL;
881: ELSE
882: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, SQLERRM);
883: raise_application_error(-20001, 'Index Creation failed: ' || sqlerrm);
884: END IF;
885:
886: END CREATE_INDEX; --Index
902: INTO lv_appl_short_nm
903: FROM fnd_application
904: WHERE application_id=724;
905:
906: IF p_schema = MSC_UTIL.G_APPS_SCHEMA THEN
907:
908: EXECUTE IMMEDIATE p_sql_stmt;
909:
910: ELSE
915: statement => p_sql_stmt,
916: object_name => p_table);
917: END IF;
918:
919: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Index '||p_index||' succesfully dropped...');
920:
921: EXCEPTION
922: WHEN OTHERS THEN
923: IF SQLCODE IN (-01418) THEN
921: EXCEPTION
922: WHEN OTHERS THEN
923: IF SQLCODE IN (-01418) THEN
924: /*Index does not exist */
925: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Index ' ||p_index||' does not exist...');
926: ELSE
927: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, SQLERRM);
928: raise_application_error(-20001, 'Dropping Index failed: ' || sqlerrm);
929: END IF;
923: IF SQLCODE IN (-01418) THEN
924: /*Index does not exist */
925: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, 'Index ' ||p_index||' does not exist...');
926: ELSE
927: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, SQLERRM);
928: raise_application_error(-20001, 'Dropping Index failed: ' || sqlerrm);
929: END IF;
930: END DROP_INDEX; --Index
931:
977: RETURN lv_schema;
978:
979: EXCEPTION
980: WHEN OTHERS THEN
981: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_FATAL_ERR, SQLERRM);
982: raise_application_error(-20001, 'Error getting the Schema : ' || sqlerrm);
983: END GET_SCHEMA_NAME;
984:
985:
1199: PROCEDURE init_dbmessage
1200: is
1201: l_count number;
1202: begin
1203: l_count := MSC_UTIL.g_dbmessage.count;
1204: if nvl(l_count,0) > 0 then
1205: MSC_UTIL.g_dbmessage.delete;
1206: end if;
1207: End init_dbmessage;
1201: l_count number;
1202: begin
1203: l_count := MSC_UTIL.g_dbmessage.count;
1204: if nvl(l_count,0) > 0 then
1205: MSC_UTIL.g_dbmessage.delete;
1206: end if;
1207: End init_dbmessage;
1208:
1209:
1212: P_Program_unit in varchar2 default null )
1213: is
1214: l_count number ;
1215: begin
1216: l_count := MSC_UTIL.g_dbmessage.count;
1217: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).msg_no := nvl(l_count , 0) + 1 ;
1218: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).msg_desc := p_msg ;
1219: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).package_name := p_Package_name ;
1220: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).program_unit := P_Program_unit ;
1213: is
1214: l_count number ;
1215: begin
1216: l_count := MSC_UTIL.g_dbmessage.count;
1217: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).msg_no := nvl(l_count , 0) + 1 ;
1218: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).msg_desc := p_msg ;
1219: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).package_name := p_Package_name ;
1220: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).program_unit := P_Program_unit ;
1221: End set_dbmessage;
1214: l_count number ;
1215: begin
1216: l_count := MSC_UTIL.g_dbmessage.count;
1217: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).msg_no := nvl(l_count , 0) + 1 ;
1218: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).msg_desc := p_msg ;
1219: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).package_name := p_Package_name ;
1220: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).program_unit := P_Program_unit ;
1221: End set_dbmessage;
1222:
1215: begin
1216: l_count := MSC_UTIL.g_dbmessage.count;
1217: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).msg_no := nvl(l_count , 0) + 1 ;
1218: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).msg_desc := p_msg ;
1219: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).package_name := p_Package_name ;
1220: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).program_unit := P_Program_unit ;
1221: End set_dbmessage;
1222:
1223: FUNCTION get_dbmessage return
1216: l_count := MSC_UTIL.g_dbmessage.count;
1217: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).msg_no := nvl(l_count , 0) + 1 ;
1218: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).msg_desc := p_msg ;
1219: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).package_name := p_Package_name ;
1220: MSC_UTIL.g_dbmessage(nvl(l_count , 0) + 1).program_unit := P_Program_unit ;
1221: End set_dbmessage;
1222:
1223: FUNCTION get_dbmessage return
1224: DbMessageTabType
1223: FUNCTION get_dbmessage return
1224: DbMessageTabType
1225: is
1226: begin
1227: return(MSC_UTIL.g_dbmessage);
1228: end get_dbmessage;
1229:
1230: /*-----------------------------------------------------------------------------
1231: Function : MSC_NUMVAL
1348: END;
1349:
1350: ------ set v_in_org_str and v_in_all_org_str----------
1351:
1352: MSC_UTIL.v_in_org_str := msc_cl_pull.get_org_str(pinstance_id,2);
1353: MSC_UTIL.v_in_all_org_str := msc_cl_pull.get_org_str(pinstance_id,3);
1354:
1355: IF MSC_UTIL.G_COLLECT_SRP_DATA = 'Y' THEN
1356: SELECT APPS_VER
1349:
1350: ------ set v_in_org_str and v_in_all_org_str----------
1351:
1352: MSC_UTIL.v_in_org_str := msc_cl_pull.get_org_str(pinstance_id,2);
1353: MSC_UTIL.v_in_all_org_str := msc_cl_pull.get_org_str(pinstance_id,3);
1354:
1355: IF MSC_UTIL.G_COLLECT_SRP_DATA = 'Y' THEN
1356: SELECT APPS_VER
1357: INTO v_apps_ver
1351:
1352: MSC_UTIL.v_in_org_str := msc_cl_pull.get_org_str(pinstance_id,2);
1353: MSC_UTIL.v_in_all_org_str := msc_cl_pull.get_org_str(pinstance_id,3);
1354:
1355: IF MSC_UTIL.G_COLLECT_SRP_DATA = 'Y' THEN
1356: SELECT APPS_VER
1357: INTO v_apps_ver
1358: FROM MSC_APPS_INSTANCES
1359: WHERE INSTANCE_ID= pINSTANCE_ID;
1357: INTO v_apps_ver
1358: FROM MSC_APPS_INSTANCES
1359: WHERE INSTANCE_ID= pINSTANCE_ID;
1360:
1361: IF (v_apps_ver<> -1 AND v_apps_ver < MSC_UTIL.G_APPS115) THEN --bug#5684183 (bcaru)
1362: MSC_UTIL.G_COLLECT_SRP_DATA := 'N' ; --SRP not supported for version < 12.1
1363: LOG_MSG(G_LVL_FATAL_ERR,'v115 SRP data is not collected because of wrong source version...');
1364: ELSE
1365: MSC_CL_PULL.GET_DEPOT_ORG_STRINGS(pINSTANCE_ID); -- For Bug 5909379
1358: FROM MSC_APPS_INSTANCES
1359: WHERE INSTANCE_ID= pINSTANCE_ID;
1360:
1361: IF (v_apps_ver<> -1 AND v_apps_ver < MSC_UTIL.G_APPS115) THEN --bug#5684183 (bcaru)
1362: MSC_UTIL.G_COLLECT_SRP_DATA := 'N' ; --SRP not supported for version < 12.1
1363: LOG_MSG(G_LVL_FATAL_ERR,'v115 SRP data is not collected because of wrong source version...');
1364: ELSE
1365: MSC_CL_PULL.GET_DEPOT_ORG_STRINGS(pINSTANCE_ID); -- For Bug 5909379
1366: END IF;
1437: and status =''VALID''
1438: ';
1439: Execute immediate lv_sql_str into lv_exists
1440: USING
1441: p_package_name,MSC_UTIL.G_APPS_SCHEMA;
1442:
1443: EXCEPTION WHEN no_data_found THEN
1444: RAISE_APPLICATION_ERROR(-20056,'Package name does not exists or is Invalid');
1445: END;
1525: PROCEDURE DROP_WRONGSCHEMA_MVIEWS IS
1526: lv_sql varchar2(1000);
1527: lv_Nologging_tblsp varchar2(30);
1528: begin
1529: for i in (SELECT mview_name,msc_util.GET_SCHEMA_NAME(erp_product_code) mview_owner
1530: FROM msc_coll_snapshots_v
1531: WHERE mview_name <> 'ALL SNAPSHOTS'
1532: UNION /*Old Mviews that need to be dropped*/
1533: Select 'BOM_CTO_ORDER_DMD_SN',msc_util.G_BOM_SCHEMA
1529: for i in (SELECT mview_name,msc_util.GET_SCHEMA_NAME(erp_product_code) mview_owner
1530: FROM msc_coll_snapshots_v
1531: WHERE mview_name <> 'ALL SNAPSHOTS'
1532: UNION /*Old Mviews that need to be dropped*/
1533: Select 'BOM_CTO_ORDER_DMD_SN',msc_util.G_BOM_SCHEMA
1534: FROM Dual)
1535: loop
1536: BEGIN
1537: lv_sql:='DROP MATERIALIZED VIEW '||I.mview_owner||'.'||i.mview_name;
1610: AND do.owner=dt.owner
1611: AND do.object_name = dt.table_NAME);
1612: BEGIN
1613:
1614: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'Deleting orphan MV container tables ');
1615:
1616: FOR c_rec IN tabWithoutMV
1617:
1618: LOOP
1619:
1620: BEGIN
1621: lv_sql_stmt := 'DROP TABLE '||c_rec.owner||'.'||c_rec.table_name;
1622:
1623: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'The Table dropped is: '||c_rec.owner||'.'||c_rec.table_name);
1624:
1625: EXECUTE IMMEDIATE lv_sql_stmt;
1626:
1627: EXCEPTION
1626:
1627: EXCEPTION
1628: WHEN OTHERS THEN
1629:
1630: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'The table FAILED to be dropped is:'||c_rec.owner||'.'||c_rec.table_name);
1631:
1632: NULL;
1633: END;
1634:
1636:
1637: EXCEPTION
1638: WHEN NO_DATA_FOUND THEN
1639:
1640: MSC_UTIL.LOG_MSG(MSC_UTIL.G_LVL_STATUS, 'No Records found for Orphan MV containers ');
1641:
1642: WHEN OTHERS THEN
1643:
1644: RAISE_APPLICATION_ERROR(-20001, 'MSCUTILSB: Error in Dropping the table ' || sqlerrm);
1685: end ;
1686:
1687: EXCEPTION
1688: WHEN OTHERS THEN
1689: RAISE_APPLICATION_ERROR(-20001,'MSC_UTIL:Error while initilizing Global Variables for Source Schema names: ' || SQLERRM);
1690: END MSC_UTIL;
1686:
1687: EXCEPTION
1688: WHEN OTHERS THEN
1689: RAISE_APPLICATION_ERROR(-20001,'MSC_UTIL:Error while initilizing Global Variables for Source Schema names: ' || SQLERRM);
1690: END MSC_UTIL;