-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
--	Name 		: ckpopsdd.sql
--	Description	: This script populates the jr_id_maps database table
--			  with GUID values for all rows in the tables SDD_DIAGRAM_SEGMENTS@R212
--								      SDD_GLOBAL_NAMES
--								      SDD_DEPENDENCIES
--
--	Date		: 30th November 1998
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

DECLARE

BEGIN

  update ck_migration_objects set ci_created = 'N' where ci_stage = 'CKPOPSDD';

  dbms_output.enable(1000000);

-- **************************************************************************
--
--				SDD_DIAGRAM_SEGMENTS
--
-- **************************************************************************

  dbms_output.put_line('* Inserting sdd_diagram_segments');

 
 -- SDD_DIAGRAM_SEGMENTS
  INSERT INTO jr_id_maps ( trans_ref               
                         , old_id                 
                         , irid                  
                         , ivid                   
                         , element_type 
                         , occur_type                   
                         , is_a_pac_element      
                         , owning_app              
                         , owning_app_id           
                         , type_id       
                         , part_of_id                             
                         , use_of_id               
                         , pop_tab )     
                  SELECT   0
                         , a.ID
                         , jr_util.get_new_irid
                         , jr_system_util.get_new_ivid
                         , 'SEG'
                         , NULL
                         , NULL
                         , NULL
                         , a.APPLICATION_SYSTEM_OWNED_BY
                         , NULL
                         , a.DIAGRAM_REFERENCE
                         , NULL
                         , 'SDD_DIAGRAM_SEGMENTS'
                    FROM  SDD_DIAGRAM_SEGMENTS@r212   a
			  WHERE a.DIAGRAM_REFERENCE in ( select id from upg_ci_dia  );


-- **************************************************************************
--
--				SDD_GLOBAL_NAMES
--
-- **************************************************************************

  dbms_output.put_line('* Inserting sdd_global_names');

-- UPG_GLOBAL_NAMES
  INSERT INTO jr_id_maps ( trans_ref               
                         , old_id                 
                         , irid                  
                         , ivid                   
                         , element_type 
                         , occur_type                   
                         , is_a_pac_element      
                         , owning_app              
                         , owning_app_id           
                         , type_id       
                         , part_of_id                             
                         , use_of_id               
                         , pop_tab )     
                  SELECT   0
                         , IRID
                         , IRID
                         , IVID
                         , 'GNAM'
                         , NULL
                         , NULL
                         , NULL
                         , NULL
                         , NULL
                         , NULL
                         , NULL
                         , 'SDD_GLOBAL_NAMES'
                    FROM  UPG_GLOBAL_NAMES   a;

-- **************************************************************************
--
--				SDD_DEPENDENCIES
--
-- **************************************************************************

  dbms_output.put_line('* Inserting sdd_dependencies');

-- UPG_DEPENDENCIES
  INSERT INTO jr_id_maps ( trans_ref               
                         , old_id                 
                         , irid                  
                         , ivid                   
                         , element_type 
                         , occur_type                   
                         , is_a_pac_element      
                         , owning_app              
                         , owning_app_id           
                         , type_id       
                         , part_of_id                             
                         , use_of_id               
                         , pop_tab )     
                  SELECT   0
                         , IRID
                         , IRID
                         , IVID
                         , 'DEP'
                         , NULL
                         , NULL
                         , NULL
                         , NULL
                         , NULL
                         , NULL
                         , NULL
                         , 'SDD_GLOBAL_NAMES'
                    FROM  UPG_DEPENDENCIES a;


    update ck_migration_objects set ci_created = 'Y' where ci_stage = 'CKPOPSDD';

    COMMIT;

EXCEPTION 
   when others then
   dbms_output.put_line (' ** Exception Raised ** ');
   dbms_output.put_line ('...ERROR: '||substrb(sqlerrm, 1, 200));
   raise;
END;
/


