REM This file updates the Meta Data tables for MR3

DECLARE

BEGIN 

    
	-- M48.001
	-- USER WITH SELECT ACCESS RIGHT IS ABLE TO MOVE ENTITY FROM APPLICATION SYSTEMS
	-- bug fix BUG 1565623 -  .
    dbms_output.put_line ('Applying Meta Data Patch M48.001');   

    delete from rm$nls_messages where utility = 'CDR' and code = 2513;

    insert into rm$nls_messages
       (lang_id,     utility,     code,      severity, text)
    values ('US',        'CDR',       2513,   1, 'Cannot move object %0!s; Insufficient delete privilege on container %1!s.');

    dbms_output.put_line ('M48.001: Complete'); 

	-- M50.001
	-- bug fix BUG 664231 - ORA-1422 WHEN ADDING USER DEFINED ASSOCIATION A22 
	--         BUG 1627253 - ORA-1422 WHEN CREATING OR LOADING USER DEFINED ASSOCIATION WITH SHORT NAME 'A22' 
    dbms_output.put_line ('Applying Meta Data Patch M50.001');

    delete from sdw_valid_structure_elements
    where vsl_type in ('A2','A23', 'A5', 'A7');
    
    delete from sdw_valid_structure_elements
    where (vsl_type    IN ('A6', 'A22')
    and   vsl_use_of  = 'TAB')
    or 
     (vsl_type    IN ('A2', 'A5', 'A7', 'A23')
      and   vsl_use_of  = 'MOD');
 
   insert into sdw_valid_structure_elements (
    IRID
   ,IVID
   ,VSL_FOR_MATRIX_DIAGRAMMER
   ,VSL_PART_OF
   ,VSL_TYPE
   ,VSL_USE_OF
   ,VSL_COMMENT
   ,VSL_CDI_ONLY )
   values (
     null
   , null
   ,'Y'
   , 'E1'
   , 'A2'
   , 'GEM'
   , 'Bug fix 1627253'
   , 'N' ); 
 
   insert into sdw_valid_structure_elements (
    IRID
   ,IVID
   ,VSL_FOR_MATRIX_DIAGRAMMER
   ,VSL_PART_OF
   ,VSL_TYPE
   ,VSL_USE_OF
   ,VSL_COMMENT
   ,VSL_CDI_ONLY )
   values (
     null
   , null
   ,'Y'
   , 'E1'
   , 'A2'
   , 'JAM'
   , 'Bug fix 1627253'
   , 'N' ); 
 
   insert into sdw_valid_structure_elements (
    IRID
   ,IVID
   ,VSL_FOR_MATRIX_DIAGRAMMER
   ,VSL_PART_OF
   ,VSL_TYPE
   ,VSL_USE_OF
   ,VSL_COMMENT
   ,VSL_CDI_ONLY )
   values (
     null
   , null
   ,'Y'
   , 'E1'
   , 'A2'
   , 'PLM'
   , 'Bug fix 1627253'
   , 'N' ); 
 
   insert into sdw_valid_structure_elements (
    IRID
   ,IVID
   ,VSL_FOR_MATRIX_DIAGRAMMER
   ,VSL_PART_OF
   ,VSL_TYPE
   ,VSL_USE_OF
   ,VSL_COMMENT
   ,VSL_CDI_ONLY )
   values (
     null
   , null
   ,'Y'
   , 'E20'
   , 'A23'
   , 'GEM'
   , 'Bug fix 1627253'
   , 'N' ); 
 
   insert into sdw_valid_structure_elements (
    IRID
   ,IVID
   ,VSL_FOR_MATRIX_DIAGRAMMER
   ,VSL_PART_OF
   ,VSL_TYPE
   ,VSL_USE_OF
   ,VSL_COMMENT
   ,VSL_CDI_ONLY )
   values (
     null
   , null
   ,'Y'
   , 'E20'
   , 'A23'
   , 'JAM'
   , 'Bug fix 1627253'
   , 'N' );
   
   insert into sdw_valid_structure_elements (
    IRID
   ,IVID
   ,VSL_FOR_MATRIX_DIAGRAMMER
   ,VSL_PART_OF
   ,VSL_TYPE
   ,VSL_USE_OF
   ,VSL_COMMENT
   ,VSL_CDI_ONLY )
   values (
     null
   , null
   ,'Y'
   , 'E20'
   , 'A23'
   , 'PLM'
   , 'Bug fix 1627253'
   , 'N' ); 
 
   insert into sdw_valid_structure_elements (
    IRID
   ,IVID
   ,VSL_FOR_MATRIX_DIAGRAMMER
   ,VSL_PART_OF
   ,VSL_TYPE
   ,VSL_USE_OF
   ,VSL_COMMENT
   ,VSL_CDI_ONLY )
   values (
     null
   , null
   ,'Y'
   , 'E4'
   , 'A5'
   , 'GEM'
   , 'Bug fix 1627253'
   , 'N' ); 
 
   insert into sdw_valid_structure_elements (
    IRID
   ,IVID
   ,VSL_FOR_MATRIX_DIAGRAMMER
   ,VSL_PART_OF
   ,VSL_TYPE
   ,VSL_USE_OF
   ,VSL_COMMENT
   ,VSL_CDI_ONLY )
   values (
     null
   , null
   ,'Y'
   , 'E4'
   , 'A5'
   , 'JAM'
   , 'Bug fix 1627253'
   , 'N' ); 
 
   insert into sdw_valid_structure_elements (
    IRID
   ,IVID
   ,VSL_FOR_MATRIX_DIAGRAMMER
   ,VSL_PART_OF
   ,VSL_TYPE
   ,VSL_USE_OF
   ,VSL_COMMENT
   ,VSL_CDI_ONLY )
   values (
     null
   , null
   ,'Y'
   , 'E4'
   , 'A5'
   , 'PLM'
   , 'Bug fix 1627253'
   , 'N' ); 
 
   insert into sdw_valid_structure_elements (
    IRID
   ,IVID
   ,VSL_FOR_MATRIX_DIAGRAMMER
   ,VSL_PART_OF
   ,VSL_TYPE
   ,VSL_USE_OF
   ,VSL_COMMENT
   ,VSL_CDI_ONLY )
   values (
     null
   , null
   ,'Y'
   , 'E5'
   , 'A7'
   , 'GEM'
   , 'Bug fix 1627253'
   , 'N' ); 
 
   insert into sdw_valid_structure_elements (
    IRID
   ,IVID
   ,VSL_FOR_MATRIX_DIAGRAMMER
   ,VSL_PART_OF
   ,VSL_TYPE
   ,VSL_USE_OF
   ,VSL_COMMENT
   ,VSL_CDI_ONLY )
   values (
     null
   , null
   ,'Y'
   , 'E5'
   , 'A7'
   , 'JAM'
   , 'Bug fix 1627253'
   , 'N' ); 
 
   insert into sdw_valid_structure_elements (
    IRID
   ,IVID
   ,VSL_FOR_MATRIX_DIAGRAMMER
   ,VSL_PART_OF
   ,VSL_TYPE
   ,VSL_USE_OF
   ,VSL_COMMENT
   ,VSL_CDI_ONLY )
   values (
     null
   , null
   ,'Y'
   , 'E5'
   , 'A7'
   , 'PLM'
   , 'Bug fix 1627253'
   , 'N' ); 

   dbms_output.put_line ('M50.001: Complete'); 

 -- Register MR3 Upgrade in the RM$PATCHES RM$PATCHES table 

	rmpatch.install('CI04012.MR3_UPGRADE');
	
	rmpatch.installed_ok;

	commit;
	
EXCEPTION

	WHEN OTHERS THEN 
		 dbms_output.put_line('* Exception Raised  ');
		 dbms_output.put_line('...ERROR: '||substrb(sqlerrm,1,240));
		 rollback work;
		 RAISE;

END;
/











