    select *
    from   i$SDD_E2 the_tab
    where  the_tab.irid=SDD_E2_ver.irid
    and    the_tab.ivid=SDD_E2_ver.ivid;
  SDD_E2_rec SDD_E2_cur%ROWTYPE;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_E2_cur;
  fetch SDD_E2_cur into SDD_E2_rec;
  close SDD_E2_cur;
  insert into i$SDD_E2
  values (
    SDD_E2_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_E2_rec.TYPES
   ,SDD_E2_rec.ELEMENT_TYPE_NAME
   ,SDD_E2_rec.DATE_CREATED
   ,SDD_E2_rec.CREATED_BY
   ,SDD_E2_rec.DATE_CHANGED
   ,SDD_E2_rec.CHANGED_BY
   ,SDD_E2_rec.NOTM
   ,SDD_E2_rec.NAME
   ,SDD_E2_rec.CRITICAL
   ,SDD_E2_rec.CSF_REF
   ,SDD_E2_rec.RELATIVE_PRIORITY
   ,SDD_E2_rec.SET_BY
   ,SDD_E2_rec.VALUE
   ,SDD_E2_rec.UNIT_OF_MEASURE
   ,SDD_E2_rec.EXTERNAL_DEPENDENCY
   ,SDD_E2_rec.CDATE_REQUIRED
   ,SDD_E2_rec.ACHIEVEMENT_COMMENT
   ,SDD_E2_rec.COMMENTS
   ,SDD_E2_rec.USRX0
   ,SDD_E2_rec.USRX9
   ,SDD_E2_rec.USRX10
   ,SDD_E2_rec.USRX11
   ,SDD_E2_rec.USRX12
   ,SDD_E2_rec.USRX13
   ,SDD_E2_rec.USRX14
   ,SDD_E2_rec.USRX15
   ,SDD_E2_rec.USRX16
   ,SDD_E2_rec.USRX17
   ,SDD_E2_rec.USRX18
   ,SDD_E2_rec.USRX19
  );
  jr_reg_ver.vercopy_dependencies(SDD_E2_ver.irid, SDD_E2_ver.ivid, new_ivid, null, copy_dependencies);
  jr_reg_ver.vercopy_dependent_objects(SDD_E2_ver.ivid, new_ivid);
  return new_ivid;
end SDD_E2_ver;
/
create or replace function PK_SDD_E2 (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_E2 the_tab_new, SDD_E2 the_tab_old
  where  the_tab_new.ivid = PK_SDD_E2.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_E2.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_E2;
/
create or replace function FK_E2_TO_E2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.CSF_REF ref_value
  from   i$SDD_E2 the_tab
  where  the_tab.ivid = FK_E2_TO_E2.object_ivid
  and    the_tab.CSF_REF is not null
  and    not exists (
             select null
             from   SDD_E2 foreign_tab
             where  the_tab.CSF_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4966, action);
  end loop;
  return is_ok;
end FK_E2_TO_E2;
/
create or replace function SDD_E20_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_E20_cur is
    select *
    from   i$SDD_E20 the_tab
    where  the_tab.irid=SDD_E20_ver.irid
    and    the_tab.ivid=SDD_E20_ver.ivid;
  SDD_E20_rec SDD_E20_cur%ROWTYPE;
  cursor SDD_A20_cur1 is
    select *
    from i$SDD_A20 the_tab
    where the_tab.parent_ivid=SDD_E20_ver.ivid;
  cursor SDD_A23_cur2 is
    select *
    from i$SDD_A23 the_tab
    where the_tab.parent_ivid=SDD_E20_ver.ivid;
  cursor SDD_A24_cur3 is
    select *
    from i$SDD_A24 the_tab
    where the_tab.parent_ivid=SDD_E20_ver.ivid;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_E20_cur;
  fetch SDD_E20_cur into SDD_E20_rec;
  close SDD_E20_cur;
  insert into i$SDD_E20
  values (
    SDD_E20_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_E20_rec.TYPES
   ,SDD_E20_rec.ELEMENT_TYPE_NAME
   ,SDD_E20_rec.DATE_CREATED
   ,SDD_E20_rec.CREATED_BY
   ,SDD_E20_rec.DATE_CHANGED
   ,SDD_E20_rec.CHANGED_BY
   ,SDD_E20_rec.NOTM
   ,SDD_E20_rec.NAME
   ,SDD_E20_rec.TYPE
   ,SDD_E20_rec.PRIMARY_USAGE
   ,SDD_E20_rec.AVAILABILITY
   ,SDD_E20_rec.MANUFACTURER
   ,SDD_E20_rec.MODEL
   ,SDD_E20_rec.PROCESSOR_DATA
   ,SDD_E20_rec.PERSON
   ,SDD_E20_rec.PHONE
   ,SDD_E20_rec.COMMENTS
   ,SDD_E20_rec.USRX0
   ,SDD_E20_rec.USRX9
   ,SDD_E20_rec.USRX10
   ,SDD_E20_rec.USRX11
   ,SDD_E20_rec.USRX12
   ,SDD_E20_rec.USRX13
   ,SDD_E20_rec.USRX14
   ,SDD_E20_rec.USRX15
   ,SDD_E20_rec.USRX16
   ,SDD_E20_rec.USRX17
   ,SDD_E20_rec.USRX18
   ,SDD_E20_rec.USRX19
  );
  jr_reg_ver.vercopy_dependencies(SDD_E20_ver.irid, SDD_E20_ver.ivid, new_ivid, null, copy_dependencies);
  for SDD_A20_rec1 in SDD_A20_cur1 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_A20
    values (
       SDD_A20_rec1.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_A20_rec1.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_A20_rec1.TYPES
     , SDD_A20_rec1.ELEMENT_TYPE_NAME
     , SDD_A20_rec1.DATE_CREATED
     , SDD_A20_rec1.CREATED_BY
     , SDD_A20_rec1.DATE_CHANGED
     , SDD_A20_rec1.CHANGED_BY
     , SDD_A20_rec1.NOTM
     , SDD_A20_rec1.PART_OF_NODE_REF
     , SDD_A20_rec1.USE_OF_NODE_REF
     , SDD_A20_rec1.PROTOCOL
     , SDD_A20_rec1.LINE_SPEED
     , SDD_A20_rec1.UOM
     , SDD_A20_rec1.CDATE_FROM
     , SDD_A20_rec1.CDATE_TO
     , SDD_A20_rec1.COMMENTS
     , SDD_A20_rec1.USRX0
     , SDD_A20_rec1.USRX6
     , SDD_A20_rec1.USRX7
     , SDD_A20_rec1.USRX8
     , SDD_A20_rec1.USRX9
     , SDD_A20_rec1.USRX10
     , SDD_A20_rec1.USRX11
     , SDD_A20_rec1.USRX12
     , SDD_A20_rec1.USRX13
     , SDD_A20_rec1.USRX14
     , SDD_A20_rec1.USRX15
     , SDD_A20_rec1.USRX16
     , SDD_A20_rec1.USRX17
     , SDD_A20_rec1.USRX18
     , SDD_A20_rec1.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_A20_rec1.irid, SDD_A20_rec1.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_A23_rec2 in SDD_A23_cur2 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_A23
    values (
       SDD_A23_rec2.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_A23_rec2.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_A23_rec2.TYPES
     , SDD_A23_rec2.ELEMENT_TYPE_NAME
     , SDD_A23_rec2.DATE_CREATED
     , SDD_A23_rec2.CREATED_BY
     , SDD_A23_rec2.DATE_CHANGED
     , SDD_A23_rec2.CHANGED_BY
     , SDD_A23_rec2.NOTM
     , SDD_A23_rec2.NODE_REF
     , SDD_A23_rec2.MODULE_REF
     , SDD_A23_rec2.FORECAST_FREQUENCY
     , SDD_A23_rec2.FREQUENCY_UOM
     , SDD_A23_rec2.REQUIRED_RESPONSE
     , SDD_A23_rec2.URGENCY
     , SDD_A23_rec2.DESIGN_NOTE
     , SDD_A23_rec2.COMMENTS
     , SDD_A23_rec2.USRX0
     , SDD_A23_rec2.USRX6
     , SDD_A23_rec2.USRX7
     , SDD_A23_rec2.USRX8
     , SDD_A23_rec2.USRX9
     , SDD_A23_rec2.USRX10
     , SDD_A23_rec2.USRX11
     , SDD_A23_rec2.USRX12
     , SDD_A23_rec2.USRX13
     , SDD_A23_rec2.USRX14
     , SDD_A23_rec2.USRX15
     , SDD_A23_rec2.USRX16
     , SDD_A23_rec2.USRX17
     , SDD_A23_rec2.USRX18
     , SDD_A23_rec2.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_A23_rec2.irid, SDD_A23_rec2.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_A24_rec3 in SDD_A24_cur3 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_A24
    values (
       SDD_A24_rec3.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_A24_rec3.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_A24_rec3.TYPES
     , SDD_A24_rec3.ELEMENT_TYPE_NAME
     , SDD_A24_rec3.DATE_CREATED
     , SDD_A24_rec3.CREATED_BY
     , SDD_A24_rec3.DATE_CHANGED
     , SDD_A24_rec3.CHANGED_BY
     , SDD_A24_rec3.NOTM
     , SDD_A24_rec3.NODE_REF
     , SDD_A24_rec3.BUSINESS_UNIT_REF
     , SDD_A24_rec3.COMMENTS
     , SDD_A24_rec3.DESCRIPTION
     , SDD_A24_rec3.MAIN_CONTACT_NAME
     , SDD_A24_rec3.MAIN_CONTACT_PHONE
     , SDD_A24_rec3.USRX0
     , SDD_A24_rec3.USRX4
     , SDD_A24_rec3.USRX5
     , SDD_A24_rec3.USRX6
     , SDD_A24_rec3.USRX7
     , SDD_A24_rec3.USRX8
     , SDD_A24_rec3.USRX9
     , SDD_A24_rec3.USRX10
     , SDD_A24_rec3.USRX11
     , SDD_A24_rec3.USRX12
     , SDD_A24_rec3.USRX13
     , SDD_A24_rec3.USRX14
     , SDD_A24_rec3.USRX15
     , SDD_A24_rec3.USRX16
     , SDD_A24_rec3.USRX17
     , SDD_A24_rec3.USRX18
     , SDD_A24_rec3.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_A24_rec3.irid, SDD_A24_rec3.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  jr_reg_ver.vercopy_dependent_objects(SDD_E20_ver.ivid, new_ivid);
  return new_ivid;
end SDD_E20_ver;
/
create or replace function PK_SDD_E20 (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_E20 the_tab_new, SDD_E20 the_tab_old
  where  the_tab_new.ivid = PK_SDD_E20.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_E20.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_E20;
/
create or replace function SDD_E3_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_E3_cur is
    select *
    from   i$SDD_E3 the_tab
    where  the_tab.irid=SDD_E3_ver.irid
    and    the_tab.ivid=SDD_E3_ver.ivid;
  SDD_E3_rec SDD_E3_cur%ROWTYPE;
  cursor SDD_A11_cur1 is
    select *
    from i$SDD_A11 the_tab
    where the_tab.parent_ivid=SDD_E3_ver.ivid;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_E3_cur;
  fetch SDD_E3_cur into SDD_E3_rec;
  close SDD_E3_cur;
  insert into i$SDD_E3
  values (
    SDD_E3_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_E3_rec.TYPES
   ,SDD_E3_rec.ELEMENT_TYPE_NAME
   ,SDD_E3_rec.DATE_CREATED
   ,SDD_E3_rec.CREATED_BY
   ,SDD_E3_rec.DATE_CHANGED
   ,SDD_E3_rec.CHANGED_BY
   ,SDD_E3_rec.NOTM
   ,SDD_E3_rec.NAME
   ,SDD_E3_rec.KPI_REF
   ,SDD_E3_rec.RESPONSIBILITY
   ,SDD_E3_rec.MEASURED_BY
   ,SDD_E3_rec.SET_BY
   ,SDD_E3_rec.TARGET_VALUE
   ,SDD_E3_rec.UNIT_OF_MEASURE
   ,SDD_E3_rec.COMMENTS
   ,SDD_E3_rec.USRX0
   ,SDD_E3_rec.USRX6
   ,SDD_E3_rec.USRX7
   ,SDD_E3_rec.USRX8
   ,SDD_E3_rec.USRX9
   ,SDD_E3_rec.USRX10
   ,SDD_E3_rec.USRX11
   ,SDD_E3_rec.USRX12
   ,SDD_E3_rec.USRX13
   ,SDD_E3_rec.USRX14
   ,SDD_E3_rec.USRX15
   ,SDD_E3_rec.USRX16
   ,SDD_E3_rec.USRX17
   ,SDD_E3_rec.USRX18
   ,SDD_E3_rec.USRX19
  );
  jr_reg_ver.vercopy_dependencies(SDD_E3_ver.irid, SDD_E3_ver.ivid, new_ivid, null, copy_dependencies);
  for SDD_A11_rec1 in SDD_A11_cur1 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_A11
    values (
       SDD_A11_rec1.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_A11_rec1.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_A11_rec1.TYPES
     , SDD_A11_rec1.ELEMENT_TYPE_NAME
     , SDD_A11_rec1.DATE_CREATED
     , SDD_A11_rec1.CREATED_BY
     , SDD_A11_rec1.DATE_CHANGED
     , SDD_A11_rec1.CHANGED_BY
     , SDD_A11_rec1.NOTM
     , SDD_A11_rec1.KPI_REF
     , SDD_A11_rec1.FUNCTION_REF
     , SDD_A11_rec1.FREQUENCY
     , SDD_A11_rec1.FREQUENCY_PERIOD
     , SDD_A11_rec1.MONITOR_OF
     , SDD_A11_rec1.REPORT_ON
     , SDD_A11_rec1.SET_BY
     , SDD_A11_rec1.DERIVATION_EXPN
     , SDD_A11_rec1.COMMENTS
     , SDD_A11_rec1.USRX0
     , SDD_A11_rec1.USRX7
     , SDD_A11_rec1.USRX8
     , SDD_A11_rec1.USRX9
     , SDD_A11_rec1.USRX10
     , SDD_A11_rec1.USRX11
     , SDD_A11_rec1.USRX12
     , SDD_A11_rec1.USRX13
     , SDD_A11_rec1.USRX14
     , SDD_A11_rec1.USRX15
     , SDD_A11_rec1.USRX16
     , SDD_A11_rec1.USRX17
     , SDD_A11_rec1.USRX18
     , SDD_A11_rec1.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_A11_rec1.irid, SDD_A11_rec1.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  jr_reg_ver.vercopy_dependent_objects(SDD_E3_ver.ivid, new_ivid);
  return new_ivid;
end SDD_E3_ver;
/
create or replace function PK_SDD_E3 (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_E3 the_tab_new, SDD_E3 the_tab_old
  where  the_tab_new.ivid = PK_SDD_E3.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_E3.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_E3;
/
create or replace function FK_E3_TO_E3 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.KPI_REF ref_value
  from   i$SDD_E3 the_tab
  where  the_tab.ivid = FK_E3_TO_E3.object_ivid
  and    the_tab.KPI_REF is not null
  and    not exists (
             select null
             from   SDD_E3 foreign_tab
             where  the_tab.KPI_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4965, action);
  end loop;
  return is_ok;
end FK_E3_TO_E3;
/
create or replace function SDD_E4_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_E4_cur is
    select *
    from   i$SDD_E4 the_tab
    where  the_tab.irid=SDD_E4_ver.irid
    and    the_tab.ivid=SDD_E4_ver.ivid;
  SDD_E4_rec SDD_E4_cur%ROWTYPE;
  cursor SDD_A5_cur1 is
    select *
    from i$SDD_A5 the_tab
    where the_tab.parent_ivid=SDD_E4_ver.ivid;
  cursor SDD_A6_cur2 is
    select *
    from i$SDD_A6 the_tab
    where the_tab.parent_ivid=SDD_E4_ver.ivid;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_E4_cur;
  fetch SDD_E4_cur into SDD_E4_rec;
  close SDD_E4_cur;
  insert into i$SDD_E4
  values (
    SDD_E4_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_E4_rec.TYPES
   ,SDD_E4_rec.ELEMENT_TYPE_NAME
   ,SDD_E4_rec.DATE_CREATED
   ,SDD_E4_rec.CREATED_BY
   ,SDD_E4_rec.DATE_CHANGED
   ,SDD_E4_rec.CHANGED_BY
   ,SDD_E4_rec.NOTM
   ,SDD_E4_rec.NAME
   ,SDD_E4_rec.TYPE
   ,SDD_E4_rec.MADE_BY
   ,SDD_E4_rec.RANKING
   ,SDD_E4_rec.STABILITY
   ,SDD_E4_rec.RISK
   ,SDD_E4_rec.COMMENTS
   ,SDD_E4_rec.USRX0
   ,SDD_E4_rec.USRX6
   ,SDD_E4_rec.USRX7
   ,SDD_E4_rec.USRX8
   ,SDD_E4_rec.USRX9
   ,SDD_E4_rec.USRX10
   ,SDD_E4_rec.USRX11
   ,SDD_E4_rec.USRX12
   ,SDD_E4_rec.USRX13
   ,SDD_E4_rec.USRX14
   ,SDD_E4_rec.USRX15
   ,SDD_E4_rec.USRX16
   ,SDD_E4_rec.USRX17
   ,SDD_E4_rec.USRX18
   ,SDD_E4_rec.USRX19
  );
  jr_reg_ver.vercopy_dependencies(SDD_E4_ver.irid, SDD_E4_ver.ivid, new_ivid, null, copy_dependencies);
  for SDD_A5_rec1 in SDD_A5_cur1 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_A5
    values (
       SDD_A5_rec1.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_A5_rec1.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_A5_rec1.TYPES
     , SDD_A5_rec1.ELEMENT_TYPE_NAME
     , SDD_A5_rec1.DATE_CREATED
     , SDD_A5_rec1.CREATED_BY
     , SDD_A5_rec1.DATE_CHANGED
     , SDD_A5_rec1.CHANGED_BY
     , SDD_A5_rec1.NOTM
     , SDD_A5_rec1.ASSUMPTION_REF
     , SDD_A5_rec1.MODULE_REF
     , SDD_A5_rec1.COMMENTS
     , SDD_A5_rec1.USRX0
     , SDD_A5_rec1.USRX1
     , SDD_A5_rec1.USRX2
     , SDD_A5_rec1.USRX3
     , SDD_A5_rec1.USRX4
     , SDD_A5_rec1.USRX5
     , SDD_A5_rec1.USRX6
     , SDD_A5_rec1.USRX7
     , SDD_A5_rec1.USRX8
     , SDD_A5_rec1.USRX9
     , SDD_A5_rec1.USRX10
     , SDD_A5_rec1.USRX11
     , SDD_A5_rec1.USRX12
     , SDD_A5_rec1.USRX13
     , SDD_A5_rec1.USRX14
     , SDD_A5_rec1.USRX15
     , SDD_A5_rec1.USRX16
     , SDD_A5_rec1.USRX17
     , SDD_A5_rec1.USRX18
     , SDD_A5_rec1.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_A5_rec1.irid, SDD_A5_rec1.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_A6_rec2 in SDD_A6_cur2 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_A6
    values (
       SDD_A6_rec2.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_A6_rec2.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_A6_rec2.TYPES
     , SDD_A6_rec2.ELEMENT_TYPE_NAME
     , SDD_A6_rec2.DATE_CREATED
     , SDD_A6_rec2.CREATED_BY
     , SDD_A6_rec2.DATE_CHANGED
     , SDD_A6_rec2.CHANGED_BY
     , SDD_A6_rec2.NOTM
     , SDD_A6_rec2.ASSUMPTION_REF
     , SDD_A6_rec2.TABLE_REF
     , SDD_A6_rec2.COMMENTS
     , SDD_A6_rec2.USRX0
     , SDD_A6_rec2.USRX1
     , SDD_A6_rec2.USRX2
     , SDD_A6_rec2.USRX3
     , SDD_A6_rec2.USRX4
     , SDD_A6_rec2.USRX5
     , SDD_A6_rec2.USRX6
     , SDD_A6_rec2.USRX7
     , SDD_A6_rec2.USRX8
     , SDD_A6_rec2.USRX9
     , SDD_A6_rec2.USRX10
     , SDD_A6_rec2.USRX11
     , SDD_A6_rec2.USRX12
     , SDD_A6_rec2.USRX13
     , SDD_A6_rec2.USRX14
     , SDD_A6_rec2.USRX15
     , SDD_A6_rec2.USRX16
     , SDD_A6_rec2.USRX17
     , SDD_A6_rec2.USRX18
     , SDD_A6_rec2.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_A6_rec2.irid, SDD_A6_rec2.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  jr_reg_ver.vercopy_dependent_objects(SDD_E4_ver.ivid, new_ivid);
  return new_ivid;
end SDD_E4_ver;
/
create or replace function PK_SDD_E4 (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_E4 the_tab_new, SDD_E4 the_tab_old
  where  the_tab_new.ivid = PK_SDD_E4.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_E4.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_E4;
/
create or replace function SDD_E5_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_E5_cur is
    select *
    from   i$SDD_E5 the_tab
    where  the_tab.irid=SDD_E5_ver.irid
    and    the_tab.ivid=SDD_E5_ver.ivid;
  SDD_E5_rec SDD_E5_cur%ROWTYPE;
  cursor SDD_A7_cur1 is
    select *
    from i$SDD_A7 the_tab
    where the_tab.parent_ivid=SDD_E5_ver.ivid;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_E5_cur;
  fetch SDD_E5_cur into SDD_E5_rec;
  close SDD_E5_cur;
  insert into i$SDD_E5
  values (
    SDD_E5_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_E5_rec.TYPES
   ,SDD_E5_rec.ELEMENT_TYPE_NAME
   ,SDD_E5_rec.DATE_CREATED
   ,SDD_E5_rec.CREATED_BY
   ,SDD_E5_rec.DATE_CHANGED
   ,SDD_E5_rec.CHANGED_BY
   ,SDD_E5_rec.NOTM
   ,SDD_E5_rec.NAME
   ,SDD_E5_rec.TYPE
   ,SDD_E5_rec.PROBLEM_REF
   ,SDD_E5_rec.IDENTIFIED_BY
   ,SDD_E5_rec.CDATE_IDENTIFIED
   ,SDD_E5_rec.CDATE_SOLVED
   ,SDD_E5_rec.OPPORTUNITIES
   ,SDD_E5_rec.CAUSE_CATEGORY
   ,SDD_E5_rec.BENEFIT
   ,SDD_E5_rec.COMMENTS
   ,SDD_E5_rec.USRX0
   ,SDD_E5_rec.USRX8
   ,SDD_E5_rec.USRX9
   ,SDD_E5_rec.USRX10
   ,SDD_E5_rec.USRX11
   ,SDD_E5_rec.USRX12
   ,SDD_E5_rec.USRX13
   ,SDD_E5_rec.USRX14
   ,SDD_E5_rec.USRX15
   ,SDD_E5_rec.USRX16
   ,SDD_E5_rec.USRX17
   ,SDD_E5_rec.USRX18
   ,SDD_E5_rec.USRX19
  );
  jr_reg_ver.vercopy_dependencies(SDD_E5_ver.irid, SDD_E5_ver.ivid, new_ivid, null, copy_dependencies);
  for SDD_A7_rec1 in SDD_A7_cur1 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_A7
    values (
       SDD_A7_rec1.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_A7_rec1.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_A7_rec1.TYPES
     , SDD_A7_rec1.ELEMENT_TYPE_NAME
     , SDD_A7_rec1.DATE_CREATED
     , SDD_A7_rec1.CREATED_BY
     , SDD_A7_rec1.DATE_CHANGED
     , SDD_A7_rec1.CHANGED_BY
     , SDD_A7_rec1.NOTM
     , SDD_A7_rec1.PROBLEM_REF
     , SDD_A7_rec1.MODULE_REF
     , SDD_A7_rec1.CONTACT
     , SDD_A7_rec1.COMMENTS
     , SDD_A7_rec1.USRX0
     , SDD_A7_rec1.USRX2
     , SDD_A7_rec1.USRX3
     , SDD_A7_rec1.USRX4
     , SDD_A7_rec1.USRX5
     , SDD_A7_rec1.USRX6
     , SDD_A7_rec1.USRX7
     , SDD_A7_rec1.USRX8
     , SDD_A7_rec1.USRX9
     , SDD_A7_rec1.USRX10
     , SDD_A7_rec1.USRX11
     , SDD_A7_rec1.USRX12
     , SDD_A7_rec1.USRX13
     , SDD_A7_rec1.USRX14
     , SDD_A7_rec1.USRX15
     , SDD_A7_rec1.USRX16
     , SDD_A7_rec1.USRX17
     , SDD_A7_rec1.USRX18
     , SDD_A7_rec1.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_A7_rec1.irid, SDD_A7_rec1.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  jr_reg_ver.vercopy_dependent_objects(SDD_E5_ver.ivid, new_ivid);
  return new_ivid;
end SDD_E5_ver;
/
create or replace function PK_SDD_E5 (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_E5 the_tab_new, SDD_E5 the_tab_old
  where  the_tab_new.ivid = PK_SDD_E5.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_E5.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_E5;
/
create or replace function FK_E5_TO_E5 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.PROBLEM_REF ref_value
  from   i$SDD_E5 the_tab
  where  the_tab.ivid = FK_E5_TO_E5.object_ivid
  and    the_tab.PROBLEM_REF is not null
  and    not exists (
             select null
             from   SDD_E5 foreign_tab
             where  the_tab.PROBLEM_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4963, action);
  end loop;
  return is_ok;
end FK_E5_TO_E5;
/
create or replace function SDD_E6_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_E6_cur is
    select *
    from   i$SDD_E6 the_tab
    where  the_tab.irid=SDD_E6_ver.irid
    and    the_tab.ivid=SDD_E6_ver.ivid;
  SDD_E6_rec SDD_E6_cur%ROWTYPE;
  cursor SDD_A21_cur1 is
    select *
    from i$SDD_A21 the_tab
    where the_tab.parent_ivid=SDD_E6_ver.ivid;
  cursor SDD_A9_cur2 is
    select *
    from i$SDD_A9 the_tab
    where the_tab.parent_ivid=SDD_E6_ver.ivid;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_E6_cur;
  fetch SDD_E6_cur into SDD_E6_rec;
  close SDD_E6_cur;
  insert into i$SDD_E6
  values (
    SDD_E6_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_E6_rec.TYPES
   ,SDD_E6_rec.ELEMENT_TYPE_NAME
   ,SDD_E6_rec.DATE_CREATED
   ,SDD_E6_rec.CREATED_BY
   ,SDD_E6_rec.DATE_CHANGED
   ,SDD_E6_rec.CHANGED_BY
   ,SDD_E6_rec.NOTM
   ,SDD_E6_rec.NAME
   ,SDD_E6_rec.TYPE
   ,SDD_E6_rec.LOCATION_REF
   ,SDD_E6_rec.CONTACT
   ,SDD_E6_rec.TELEPHONE_NUMBER
   ,SDD_E6_rec.ADDRESS_LINE_1
   ,SDD_E6_rec.ADDRESS_LINE_2
   ,SDD_E6_rec.CODE
   ,SDD_E6_rec.COORDINATE_1
   ,SDD_E6_rec.COORDINATE_2
   ,SDD_E6_rec.COMMENTS
   ,SDD_E6_rec.USRX0
   ,SDD_E6_rec.USRX9
   ,SDD_E6_rec.USRX10
   ,SDD_E6_rec.USRX11
   ,SDD_E6_rec.USRX12
   ,SDD_E6_rec.USRX13
   ,SDD_E6_rec.USRX14
   ,SDD_E6_rec.USRX15
   ,SDD_E6_rec.USRX16
   ,SDD_E6_rec.USRX17
   ,SDD_E6_rec.USRX18
   ,SDD_E6_rec.USRX19
  );
  jr_reg_ver.vercopy_dependencies(SDD_E6_ver.irid, SDD_E6_ver.ivid, new_ivid, null, copy_dependencies);
  for SDD_A21_rec1 in SDD_A21_cur1 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_A21
    values (
       SDD_A21_rec1.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_A21_rec1.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_A21_rec1.TYPES
     , SDD_A21_rec1.ELEMENT_TYPE_NAME
     , SDD_A21_rec1.DATE_CREATED
     , SDD_A21_rec1.CREATED_BY
     , SDD_A21_rec1.DATE_CHANGED
     , SDD_A21_rec1.CHANGED_BY
     , SDD_A21_rec1.NOTM
     , SDD_A21_rec1.LOCATION_REF
     , SDD_A21_rec1.NODE_REF
     , SDD_A21_rec1.CDATE_FROM
     , SDD_A21_rec1.CDATE_TO
     , SDD_A21_rec1.INSTALLERS_NAME
     , SDD_A21_rec1.CONTACT_PHONE_NUMBER
     , SDD_A21_rec1.COMMENTS
     , SDD_A21_rec1.USRX0
     , SDD_A21_rec1.USRX5
     , SDD_A21_rec1.USRX6
     , SDD_A21_rec1.USRX7
     , SDD_A21_rec1.USRX8
     , SDD_A21_rec1.USRX9
     , SDD_A21_rec1.USRX10
     , SDD_A21_rec1.USRX11
     , SDD_A21_rec1.USRX12
     , SDD_A21_rec1.USRX13
     , SDD_A21_rec1.USRX14
     , SDD_A21_rec1.USRX15
     , SDD_A21_rec1.USRX16
     , SDD_A21_rec1.USRX17
     , SDD_A21_rec1.USRX18
     , SDD_A21_rec1.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_A21_rec1.irid, SDD_A21_rec1.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_A9_rec2 in SDD_A9_cur2 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_A9
    values (
       SDD_A9_rec2.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_A9_rec2.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_A9_rec2.TYPES
     , SDD_A9_rec2.ELEMENT_TYPE_NAME
     , SDD_A9_rec2.DATE_CREATED
     , SDD_A9_rec2.CREATED_BY
     , SDD_A9_rec2.DATE_CHANGED
     , SDD_A9_rec2.CHANGED_BY
     , SDD_A9_rec2.NOTM
     , SDD_A9_rec2.LOCATION_REF
     , SDD_A9_rec2.BUSINESS_UNIT_REF
     , SDD_A9_rec2.CDATE_EFFECTIVE
     , SDD_A9_rec2.SET_BY
     , SDD_A9_rec2.HEADCOUNT
     , SDD_A9_rec2.HCUNIT_OF_MEASURE
     , SDD_A9_rec2.BUDGET
     , SDD_A9_rec2.BUNIT_OF_MEASURE
     , SDD_A9_rec2.COMMENTS
     , SDD_A9_rec2.USRX0
     , SDD_A9_rec2.USRX7
     , SDD_A9_rec2.USRX8
     , SDD_A9_rec2.USRX9
     , SDD_A9_rec2.USRX10
     , SDD_A9_rec2.USRX11
     , SDD_A9_rec2.USRX12
     , SDD_A9_rec2.USRX13
     , SDD_A9_rec2.USRX14
     , SDD_A9_rec2.USRX15
     , SDD_A9_rec2.USRX16
     , SDD_A9_rec2.USRX17
     , SDD_A9_rec2.USRX18
     , SDD_A9_rec2.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_A9_rec2.irid, SDD_A9_rec2.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  jr_reg_ver.vercopy_dependent_objects(SDD_E6_ver.ivid, new_ivid);
  return new_ivid;
end SDD_E6_ver;
/
create or replace function PK_SDD_E6 (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_E6 the_tab_new, SDD_E6 the_tab_old
  where  the_tab_new.ivid = PK_SDD_E6.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_E6.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_E6;
/
create or replace function FK_E6_TO_E6 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.LOCATION_REF ref_value
  from   i$SDD_E6 the_tab
  where  the_tab.ivid = FK_E6_TO_E6.object_ivid
  and    the_tab.LOCATION_REF is not null
  and    not exists (
             select null
             from   SDD_E6 foreign_tab
             where  the_tab.LOCATION_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4962, action);
  end loop;
  return is_ok;
end FK_E6_TO_E6;
/
create or replace function FK_ENT_TO_ENT_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_ENT child_tab
  where  child_tab.SUPERTYPE_REF=FK_ENT_TO_ENT_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_ENT child_tab, i$sdd_object_versions o
    where  child_tab.SUPERTYPE_REF=FK_ENT_TO_ENT_d.IRID
    and    child_tab.ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_ENT_TO_ENT_d;
/
create or replace function FK_EVT_TO_ENT_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_EVT child_tab
  where  child_tab.ENTITY_REF=FK_EVT_TO_ENT_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_EVT child_tab, i$sdd_object_versions o
    where  child_tab.ENTITY_REF=FK_EVT_TO_ENT_d.IRID
    and    child_tab.ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_EVT_TO_ENT_d;
/
create or replace function FK_EXT_TO_ENT_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_EXT child_tab
  where  child_tab.ENTITY_REF=FK_EXT_TO_ENT_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_EXT child_tab, i$sdd_object_versions o
    where  child_tab.ENTITY_REF=FK_EXT_TO_ENT_d.IRID
    and    child_tab.ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_EXT_TO_ENT_d;
/
create or replace function FK_FUNENT_TO_ENT_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_FUNENT child_tab
  where  child_tab.ENTITY_REF=FK_FUNENT_TO_ENT_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_FUNENT child_tab, i$sdd_object_versions o
    where  child_tab.ENTITY_REF=FK_FUNENT_TO_ENT_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_FUNENT_TO_ENT_d;
/
create or replace function SDD_ENT_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_ENT_cur is
    select *
    from   i$SDD_ENT the_tab
    where  the_tab.irid=SDD_ENT_ver.irid
    and    the_tab.ivid=SDD_ENT_ver.ivid;
  SDD_ENT_rec SDD_ENT_cur%ROWTYPE;
  cursor SDD_ATT_cur1 is
    select *
    from i$SDD_ATT the_tab
    where the_tab.parent_ivid=SDD_ENT_ver.ivid;
  cursor SDD_ATV_cur2 is
    select *
    from i$SDD_ATV the_tab
    where the_tab.parent_ivid=SDD_ENT_ver.ivid;
  cursor SDD_ENTBUN_cur3 is
    select *
    from i$SDD_ENTBUN the_tab
    where the_tab.parent_ivid=SDD_ENT_ver.ivid;
  cursor SDD_RELEND_cur4 is
    select *
    from i$SDD_RELEND the_tab
    where the_tab.parent_ivid=SDD_ENT_ver.ivid;
  cursor SDD_UID_cur5 is
    select *
    from i$SDD_UID the_tab
    where the_tab.parent_ivid=SDD_ENT_ver.ivid;
  cursor SDD_ENTUIE_cur6 is
    select *
    from i$SDD_ENTUIE the_tab
    where the_tab.parent_ivid=SDD_ENT_ver.ivid;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_ENT_cur;
  fetch SDD_ENT_cur into SDD_ENT_rec;
  close SDD_ENT_cur;
  insert into i$SDD_ENT
  values (
    SDD_ENT_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_ENT_rec.TYPES
   ,SDD_ENT_rec.ELEMENT_TYPE_NAME
   ,SDD_ENT_rec.DATE_CREATED
   ,SDD_ENT_rec.CREATED_BY
   ,SDD_ENT_rec.DATE_CHANGED
   ,SDD_ENT_rec.CHANGED_BY
   ,SDD_ENT_rec.NOTM
   ,SDD_ENT_rec.NAME
   ,SDD_ENT_rec.SHORT_NAME
   ,SDD_ENT_rec.PLURAL
   ,SDD_ENT_rec.SUPERTYPE_REF
   ,SDD_ENT_rec.INITIAL_VOLUME
   ,SDD_ENT_rec.VOLUME
   ,SDD_ENT_rec.MAXIMUM_VOLUME
   ,SDD_ENT_rec.ANNUAL_GROWTH_RATE
   ,SDD_ENT_rec.DATAWAREHOUSE_TYPE
   ,SDD_ENT_rec.INSTANTIABLE_FLAG
   ,SDD_ENT_rec.USRX0
   ,SDD_ENT_rec.USRX1
   ,SDD_ENT_rec.USRX2
   ,SDD_ENT_rec.USRX3
   ,SDD_ENT_rec.USRX4
   ,SDD_ENT_rec.USRX5
   ,SDD_ENT_rec.USRX6
   ,SDD_ENT_rec.USRX7
   ,SDD_ENT_rec.USRX8
   ,SDD_ENT_rec.USRX9
   ,SDD_ENT_rec.USRX10
   ,SDD_ENT_rec.USRX11
   ,SDD_ENT_rec.USRX12
   ,SDD_ENT_rec.USRX13
   ,SDD_ENT_rec.USRX14
   ,SDD_ENT_rec.USRX15
   ,SDD_ENT_rec.USRX16
   ,SDD_ENT_rec.USRX17
   ,SDD_ENT_rec.USRX18
   ,SDD_ENT_rec.USRX19
  );
  jr_reg_ver.vercopy_dependencies(SDD_ENT_ver.irid, SDD_ENT_ver.ivid, new_ivid, null, copy_dependencies);
  for SDD_ATT_rec1 in SDD_ATT_cur1 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ATT
    values (
       SDD_ATT_rec1.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ATT_rec1.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ATT_rec1.TYPES
     , SDD_ATT_rec1.ELEMENT_TYPE_NAME
     , SDD_ATT_rec1.DATE_CREATED
     , SDD_ATT_rec1.CREATED_BY
     , SDD_ATT_rec1.DATE_CHANGED
     , SDD_ATT_rec1.CHANGED_BY
     , SDD_ATT_rec1.NOTM
     , SDD_ATT_rec1.ENTITY_REF
     , SDD_ATT_rec1.NAME
     , SDD_ATT_rec1.SEQUENCE_NUMBER
     , SDD_ATT_rec1.DOMAIN_REF
     , SDD_ATT_rec1.FORMAT
     , SDD_ATT_rec1.AVERAGE_LENGTH
     , SDD_ATT_rec1.MAXIMUM_LENGTH
     , SDD_ATT_rec1.PRECISION
     , SDD_ATT_rec1.OPTIONAL_FLAG
     , SDD_ATT_rec1.OPTION_CONDITION
     , SDD_ATT_rec1.UNIT_OF_MEASURE
     , SDD_ATT_rec1.DEFAULT_VALUE
     , SDD_ATT_rec1.NULL_VALUE
     , SDD_ATT_rec1.DERIVATION
     , SDD_ATT_rec1.INITIAL_USAGE
     , SDD_ATT_rec1.AVERAGE_USAGE
     , SDD_ATT_rec1.SHORT_NAME
     , SDD_ATT_rec1.AUTHORITY
     , SDD_ATT_rec1.RESPONSIBLE
     , SDD_ATT_rec1.NOTES
     , SDD_ATT_rec1.ORDER_SEQUENCE
     , SDD_ATT_rec1.SORTING_ORDER
     , SDD_ATT_rec1.USRX0
     , SDD_ATT_rec1.USRX1
     , SDD_ATT_rec1.USRX2
     , SDD_ATT_rec1.USRX3
     , SDD_ATT_rec1.USRX4
     , SDD_ATT_rec1.USRX5
     , SDD_ATT_rec1.USRX6
     , SDD_ATT_rec1.USRX7
     , SDD_ATT_rec1.USRX8
     , SDD_ATT_rec1.USRX9
     , SDD_ATT_rec1.USRX10
     , SDD_ATT_rec1.USRX11
     , SDD_ATT_rec1.USRX12
     , SDD_ATT_rec1.USRX13
     , SDD_ATT_rec1.USRX14
     , SDD_ATT_rec1.USRX15
     , SDD_ATT_rec1.USRX16
     , SDD_ATT_rec1.USRX17
     , SDD_ATT_rec1.USRX18
     , SDD_ATT_rec1.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ATT_rec1.irid, SDD_ATT_rec1.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_ATV_rec2 in SDD_ATV_cur2 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ATV
    values (
       SDD_ATV_rec2.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ATV_rec2.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ATV_rec2.TYPES
     , SDD_ATV_rec2.ELEMENT_TYPE_NAME
     , SDD_ATV_rec2.DATE_CREATED
     , SDD_ATV_rec2.CREATED_BY
     , SDD_ATV_rec2.DATE_CHANGED
     , SDD_ATV_rec2.CHANGED_BY
     , SDD_ATV_rec2.NOTM
     , SDD_ATV_rec2.ATTRIBUTE_REF
     , SDD_ATV_rec2.DOMAIN_REF
     , SDD_ATV_rec2.COLUMN_REF
     , SDD_ATV_rec2.MODULE_ARGUMENT_REF
     , SDD_ATV_rec2.UNBOUND_ITEM_REF
     , SDD_ATV_rec2.LOW_VALUE
     , SDD_ATV_rec2.HIGH_VALUE
     , SDD_ATV_rec2.ABBREVIATION
     , SDD_ATV_rec2.LOW_VALUE_TYPE
     , SDD_ATV_rec2.MEANING
     , SDD_ATV_rec2.HIGH_VALUE_TYPE
     , SDD_ATV_rec2.RADIO_SEQUENCE
     , SDD_ATV_rec2.ATTRIBUTE_VALUE_FOR
     , SDD_ATV_rec2.USRX0
     , SDD_ATV_rec2.USRX1
     , SDD_ATV_rec2.USRX2
     , SDD_ATV_rec2.USRX3
     , SDD_ATV_rec2.USRX4
     , SDD_ATV_rec2.USRX5
     , SDD_ATV_rec2.USRX6
     , SDD_ATV_rec2.USRX7
     , SDD_ATV_rec2.USRX8
     , SDD_ATV_rec2.USRX9
     , SDD_ATV_rec2.USRX10
     , SDD_ATV_rec2.USRX11
     , SDD_ATV_rec2.USRX12
     , SDD_ATV_rec2.USRX13
     , SDD_ATV_rec2.USRX14
     , SDD_ATV_rec2.USRX15
     , SDD_ATV_rec2.USRX16
     , SDD_ATV_rec2.USRX17
     , SDD_ATV_rec2.USRX18
     , SDD_ATV_rec2.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ATV_rec2.irid, SDD_ATV_rec2.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_ENTBUN_rec3 in SDD_ENTBUN_cur3 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ENTBUN
    values (
       SDD_ENTBUN_rec3.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ENTBUN_rec3.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ENTBUN_rec3.TYPES
     , SDD_ENTBUN_rec3.ELEMENT_TYPE_NAME
     , SDD_ENTBUN_rec3.DATE_CREATED
     , SDD_ENTBUN_rec3.CREATED_BY
     , SDD_ENTBUN_rec3.DATE_CHANGED
     , SDD_ENTBUN_rec3.CHANGED_BY
     , SDD_ENTBUN_rec3.NOTM
     , SDD_ENTBUN_rec3.BUSINESS_UNIT_REF
     , SDD_ENTBUN_rec3.ENTITY_REF
     , SDD_ENTBUN_rec3.INITIAL_VOLUME
     , SDD_ENTBUN_rec3.AVERAGE_VOLUME
     , SDD_ENTBUN_rec3.MAXIMUM_VOLUME
     , SDD_ENTBUN_rec3.ANNUAL_GROWTH
     , SDD_ENTBUN_rec3.USRX0
     , SDD_ENTBUN_rec3.USRX1
     , SDD_ENTBUN_rec3.USRX2
     , SDD_ENTBUN_rec3.USRX3
     , SDD_ENTBUN_rec3.USRX4
     , SDD_ENTBUN_rec3.USRX5
     , SDD_ENTBUN_rec3.USRX6
     , SDD_ENTBUN_rec3.USRX7
     , SDD_ENTBUN_rec3.USRX8
     , SDD_ENTBUN_rec3.USRX9
     , SDD_ENTBUN_rec3.USRX10
     , SDD_ENTBUN_rec3.USRX11
     , SDD_ENTBUN_rec3.USRX12
     , SDD_ENTBUN_rec3.USRX13
     , SDD_ENTBUN_rec3.USRX14
     , SDD_ENTBUN_rec3.USRX15
     , SDD_ENTBUN_rec3.USRX16
     , SDD_ENTBUN_rec3.USRX17
     , SDD_ENTBUN_rec3.USRX18
     , SDD_ENTBUN_rec3.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ENTBUN_rec3.irid, SDD_ENTBUN_rec3.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_RELEND_rec4 in SDD_RELEND_cur4 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_RELEND
    values (
       SDD_RELEND_rec4.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_RELEND_rec4.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_RELEND_rec4.TYPES
     , SDD_RELEND_rec4.ELEMENT_TYPE_NAME
     , SDD_RELEND_rec4.DATE_CREATED
     , SDD_RELEND_rec4.CREATED_BY
     , SDD_RELEND_rec4.DATE_CHANGED
     , SDD_RELEND_rec4.CHANGED_BY
     , SDD_RELEND_rec4.NOTM
     , SDD_RELEND_rec4.FROM_ENTITY_REF
     , SDD_RELEND_rec4.NAME
     , SDD_RELEND_rec4.MINIMUM_CARDINALITY
     , SDD_RELEND_rec4.MAXIMUM_CARDINALITY
     , SDD_RELEND_rec4.ARC_NUMBER
     , SDD_RELEND_rec4.TRANSFER
     , SDD_RELEND_rec4.AVERAGE_VOLUME
     , SDD_RELEND_rec4.MINIMUM_VOLUME
     , SDD_RELEND_rec4.MAXIMUM_VOLUME
     , SDD_RELEND_rec4.TO_ENTITY_REF
     , SDD_RELEND_rec4.ARC_REFERENCE
     , SDD_RELEND_rec4.REMARK
     , SDD_RELEND_rec4.OTHER_RELATIONSHIP_END_REF
     , SDD_RELEND_rec4.ACCESS_CONTROL_FLAG
     , SDD_RELEND_rec4.USRX0
     , SDD_RELEND_rec4.USRX1
     , SDD_RELEND_rec4.USRX2
     , SDD_RELEND_rec4.USRX3
     , SDD_RELEND_rec4.USRX4
     , SDD_RELEND_rec4.USRX5
     , SDD_RELEND_rec4.USRX6
     , SDD_RELEND_rec4.USRX7
     , SDD_RELEND_rec4.USRX8
     , SDD_RELEND_rec4.USRX9
     , SDD_RELEND_rec4.USRX10
     , SDD_RELEND_rec4.USRX11
     , SDD_RELEND_rec4.USRX12
     , SDD_RELEND_rec4.USRX13
     , SDD_RELEND_rec4.USRX14
     , SDD_RELEND_rec4.USRX15
     , SDD_RELEND_rec4.USRX16
     , SDD_RELEND_rec4.USRX17
     , SDD_RELEND_rec4.USRX18
     , SDD_RELEND_rec4.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_RELEND_rec4.irid, SDD_RELEND_rec4.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_UID_rec5 in SDD_UID_cur5 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_UID
    values (
       SDD_UID_rec5.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_UID_rec5.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_UID_rec5.TYPES
     , SDD_UID_rec5.ELEMENT_TYPE_NAME
     , SDD_UID_rec5.DATE_CREATED
     , SDD_UID_rec5.CREATED_BY
     , SDD_UID_rec5.DATE_CHANGED
     , SDD_UID_rec5.CHANGED_BY
     , SDD_UID_rec5.NOTM
     , SDD_UID_rec5.ENTITY_REF
     , SDD_UID_rec5.NAME
     , SDD_UID_rec5.PRIMARY_UID_FLAG
     , SDD_UID_rec5.USRX0
     , SDD_UID_rec5.USRX1
     , SDD_UID_rec5.USRX2
     , SDD_UID_rec5.USRX3
     , SDD_UID_rec5.USRX4
     , SDD_UID_rec5.USRX5
     , SDD_UID_rec5.USRX6
     , SDD_UID_rec5.USRX7
     , SDD_UID_rec5.USRX8
     , SDD_UID_rec5.USRX9
     , SDD_UID_rec5.USRX10
     , SDD_UID_rec5.USRX11
     , SDD_UID_rec5.USRX12
     , SDD_UID_rec5.USRX13
     , SDD_UID_rec5.USRX14
     , SDD_UID_rec5.USRX15
     , SDD_UID_rec5.USRX16
     , SDD_UID_rec5.USRX17
     , SDD_UID_rec5.USRX18
     , SDD_UID_rec5.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_UID_rec5.irid, SDD_UID_rec5.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_ENTUIE_rec6 in SDD_ENTUIE_cur6 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ENTUIE
    values (
       SDD_ENTUIE_rec6.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ENTUIE_rec6.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ENTUIE_rec6.TYPES
     , SDD_ENTUIE_rec6.ELEMENT_TYPE_NAME
     , SDD_ENTUIE_rec6.DATE_CREATED
     , SDD_ENTUIE_rec6.CREATED_BY
     , SDD_ENTUIE_rec6.DATE_CHANGED
     , SDD_ENTUIE_rec6.CHANGED_BY
     , SDD_ENTUIE_rec6.NOTM
     , SDD_ENTUIE_rec6.UNIQUE_IDENTIFIER_REF
     , SDD_ENTUIE_rec6.ATTRIBUTE_REF
     , SDD_ENTUIE_rec6.RELATIONSHIP_END_REF
     , SDD_ENTUIE_rec6.SEQUENCE_WITHIN_UID
     , SDD_ENTUIE_rec6.ATTRIBUTE_OR_RELATION
     , SDD_ENTUIE_rec6.USRX0
     , SDD_ENTUIE_rec6.USRX1
     , SDD_ENTUIE_rec6.USRX2
     , SDD_ENTUIE_rec6.USRX3
     , SDD_ENTUIE_rec6.USRX4
     , SDD_ENTUIE_rec6.USRX5
     , SDD_ENTUIE_rec6.USRX6
     , SDD_ENTUIE_rec6.USRX7
     , SDD_ENTUIE_rec6.USRX8
     , SDD_ENTUIE_rec6.USRX9
     , SDD_ENTUIE_rec6.USRX10
     , SDD_ENTUIE_rec6.USRX11
     , SDD_ENTUIE_rec6.USRX12
     , SDD_ENTUIE_rec6.USRX13
     , SDD_ENTUIE_rec6.USRX14
     , SDD_ENTUIE_rec6.USRX15
     , SDD_ENTUIE_rec6.USRX16
     , SDD_ENTUIE_rec6.USRX17
     , SDD_ENTUIE_rec6.USRX18
     , SDD_ENTUIE_rec6.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ENTUIE_rec6.irid, SDD_ENTUIE_rec6.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  jr_reg_ver.vercopy_dependent_objects(SDD_ENT_ver.ivid, new_ivid);
  return new_ivid;
end SDD_ENT_ver;
/
create or replace function PK_SDD_ENT (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_ENT the_tab_new, SDD_ENT the_tab_old
  where  the_tab_new.ivid = PK_SDD_ENT.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_ENT.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_ENT;
/
create or replace function FK_ENT_TO_ENT (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.SUPERTYPE_REF ref_value
  from   i$SDD_ENT the_tab
  where  the_tab.ivid = FK_ENT_TO_ENT.object_ivid
  and    the_tab.SUPERTYPE_REF is not null
  and    not exists (
             select null
             from   SDD_ENT foreign_tab
             where  the_tab.SUPERTYPE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5002, action);
  end loop;
  return is_ok;
end FK_ENT_TO_ENT;
/
create or replace function PK_SDD_ENTBUN (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_ENTBUN the_tab_new, SDD_ENTBUN the_tab_old
  where  the_tab_new.ivid = PK_SDD_ENTBUN.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_ENTBUN.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_ENTBUN;
/
create or replace function FK_ENTBUN_TO_BUN (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.BUSINESS_UNIT_REF ref_value
  from   i$SDD_ENTBUN the_tab
  where  the_tab.ivid = FK_ENTBUN_TO_BUN.object_ivid
  and    the_tab.BUSINESS_UNIT_REF is not null
  and    not exists (
             select null
             from   SDD_BUN foreign_tab
             where  the_tab.BUSINESS_UNIT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5005, action);
  end loop;
  return is_ok;
end FK_ENTBUN_TO_BUN;
/
create or replace function PK_SDD_ENTUIE (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_ENTUIE the_tab_new, SDD_ENTUIE the_tab_old
  where  the_tab_new.ivid = PK_SDD_ENTUIE.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_ENTUIE.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_ENTUIE;
/
create or replace function FK_ENTUIE_TO_ATT (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ATTRIBUTE_REF ref_value
  from   i$SDD_ENTUIE the_tab
  where  the_tab.ivid = FK_ENTUIE_TO_ATT.object_ivid
  and    the_tab.ATTRIBUTE_REF is not null
  and    not exists (
             select null
             from   SDD_ATT foreign_tab
             where  the_tab.ATTRIBUTE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5010, action);
  end loop;
  return is_ok;
end FK_ENTUIE_TO_ATT;
/
create or replace function FK_ENTUIE_TO_RELEND (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.RELATIONSHIP_END_REF ref_value
  from   i$SDD_ENTUIE the_tab
  where  the_tab.ivid = FK_ENTUIE_TO_RELEND.object_ivid
  and    the_tab.RELATIONSHIP_END_REF is not null
  and    not exists (
             select null
             from   SDD_RELEND foreign_tab
             where  the_tab.RELATIONSHIP_END_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5025, action);
  end loop;
  return is_ok;
end FK_ENTUIE_TO_RELEND;
/
create or replace function PK_SDD_EOU (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_EOU the_tab_new, SDD_EOU the_tab_old
  where  the_tab_new.ivid = PK_SDD_EOU.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_EOU.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_EOU;
/
create or replace function FK_EOU_TO_EOC (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ENTITY_OBJECT_REF ref_value
  from   i$SDD_EOU the_tab
  where  the_tab.ivid = FK_EOU_TO_EOC.object_ivid
  and    the_tab.ENTITY_OBJECT_REF is not null
  and    not exists (
             select null
             from   SDD_CLA foreign_tab
             where  the_tab.ENTITY_OBJECT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4841, action);
  end loop;
  return is_ok;
end FK_EOU_TO_EOC;
/
create or replace function PK_SDD_ELRUL (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_ERU the_tab_new, SDD_ERU the_tab_old
  where  the_tab_new.ivid = PK_SDD_ELRUL.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_ELRUL.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_ELRUL;
/
create or replace function UK_ERU (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_ERU the_tab_new, SDD_ERU the_tab_old
  where  the_tab_new.ivid = UK_ERU.ivid
  and    the_tab_new.CIELEMENT_REF = the_tab_old.CIELEMENT_REF
  and    the_tab_new.UML_RULE_REF = the_tab_old.UML_RULE_REF
  and    the_tab_old.ivid != UK_ERU.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end UK_ERU;
/
create or replace function FK_ERU_TO_URU (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.UML_RULE_REF ref_value
  from   i$SDD_ERU the_tab
  where  the_tab.ivid = FK_ERU_TO_URU.object_ivid
  and    the_tab.UML_RULE_REF is not null
  and    not exists (
             select null
             from   SDD_URU foreign_tab
             where  the_tab.UML_RULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5089, action);
  end loop;
  return is_ok;
end FK_ERU_TO_URU;
/
create or replace function PK_SDD_EVH (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_EVH the_tab_new, SDD_EVH the_tab_old
  where  the_tab_new.ivid = PK_SDD_EVH.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_EVH.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_EVH;
/
create or replace function FK_EVH_TO_EVS (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.EVENT_SUBSCRIPTION_REF ref_value
  from   i$SDD_EVH the_tab
  where  the_tab.ivid = FK_EVH_TO_EVS.object_ivid
  and    the_tab.EVENT_SUBSCRIPTION_REF is not null
  and    not exists (
             select null
             from   SDD_EVS foreign_tab
             where  the_tab.EVENT_SUBSCRIPTION_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5083, action);
  end loop;
  return is_ok;
end FK_EVH_TO_EVS;
/
create or replace function FK_EVH_TO_SUD (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.SUBSCRIPTION_DETAIL_REF ref_value
  from   i$SDD_EVH the_tab
  where  the_tab.ivid = FK_EVH_TO_SUD.object_ivid
  and    the_tab.SUBSCRIPTION_DETAIL_REF is not null
  and    not exists (
             select null
             from   SDD_SUD foreign_tab
             where  the_tab.SUBSCRIPTION_DETAIL_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5084, action);
  end loop;
  return is_ok;
end FK_EVH_TO_SUD;
/
create or replace function FK_CMA_TO_EVR2_cmd (irid number, ivid number) return boolean as
cursor bad_cur is
  select child_tab.irid child_irid, child_tab.types child_type
        ,parent_tab.ivid par_ivid, parent_tab.types par_type
  from   SDD_CMA child_tab, i$SDD_EVR parent_tab
  where  parent_tab.parent_ivid=FK_CMA_TO_EVR2_cmd.ivid
  and    child_tab.EVENT_RAISER_FROM_REF=parent_tab.IRID
  ;
  is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
   insert into I$SDD_INVALID_OBJECTS(object_irid,object_ivid,table_irid)
    select o.irid,o.ivid,o.table_irid
      from SDD_CMA child_tab
          ,i$SDD_EVR parent_tab
          ,I$SDD_OBJECT_VERSIONS o
     where parent_tab.parent_ivid=FK_CMA_TO_EVR2_cmd.ivid
       and child_tab.EVENT_RAISER_FROM_REF=parent_tab.IRID
       and child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(ref.par_ivid,ref.par_type,ref.child_irid,ref.child_type,'DEL');
  end loop;
  return is_ok;
end FK_CMA_TO_EVR2_cmd;
/
create or replace function FK_CMA_TO_EVR2_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_CMA child_tab
  where  child_tab.EVENT_RAISER_FROM_REF=FK_CMA_TO_EVR2_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_CMA child_tab, i$sdd_object_versions o
    where  child_tab.EVENT_RAISER_FROM_REF=FK_CMA_TO_EVR2_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_CMA_TO_EVR2_d;
/
create or replace function PK_SDD_EVR (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_EVR the_tab_new, SDD_EVR the_tab_old
  where  the_tab_new.ivid = PK_SDD_EVR.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_EVR.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_EVR;
/
create or replace function FK_EVR_TO_CLAEVC (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.EVENT_PUBLICATION_REF ref_value
  from   i$SDD_EVR the_tab
  where  the_tab.ivid = FK_EVR_TO_CLAEVC.object_ivid
  and    the_tab.EVENT_PUBLICATION_REF is not null
  and    not exists (
             select null
             from   SDD_CLAEVC foreign_tab
             where  the_tab.EVENT_PUBLICATION_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5081, action);
  end loop;
  return is_ok;
end FK_EVR_TO_CLAEVC;
/
create or replace function FK_EVH_TO_EVS_cmd (irid number, ivid number) return boolean as
cursor bad_cur is
  select child_tab.irid child_irid, child_tab.types child_type
        ,parent_tab.ivid par_ivid, parent_tab.types par_type
  from   SDD_EVH child_tab, i$SDD_EVS parent_tab
  where  parent_tab.parent_ivid=FK_EVH_TO_EVS_cmd.ivid
  and    child_tab.EVENT_SUBSCRIPTION_REF=parent_tab.IRID
  ;
  is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
   insert into I$SDD_INVALID_OBJECTS(object_irid,object_ivid,table_irid)
    select o.irid,o.ivid,o.table_irid
      from SDD_EVH child_tab
          ,i$SDD_EVS parent_tab
          ,I$SDD_OBJECT_VERSIONS o
     where parent_tab.parent_ivid=FK_EVH_TO_EVS_cmd.ivid
       and child_tab.EVENT_SUBSCRIPTION_REF=parent_tab.IRID
       and child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(ref.par_ivid,ref.par_type,ref.child_irid,ref.child_type,'DEL');
  end loop;
  return is_ok;
end FK_EVH_TO_EVS_cmd;
/
create or replace function FK_EVH_TO_EVS_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_EVH child_tab
  where  child_tab.EVENT_SUBSCRIPTION_REF=FK_EVH_TO_EVS_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_EVH child_tab, i$sdd_object_versions o
    where  child_tab.EVENT_SUBSCRIPTION_REF=FK_EVH_TO_EVS_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_EVH_TO_EVS_d;
/
create or replace function PK_SDD_EVS (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_EVS the_tab_new, SDD_EVS the_tab_old
  where  the_tab_new.ivid = PK_SDD_EVS.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_EVS.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_EVS;
/
create or replace function FK_EVS_TO_EVC (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.EVENT_CLASSIFIER_REF ref_value
  from   i$SDD_EVS the_tab
  where  the_tab.ivid = FK_EVS_TO_EVC.object_ivid
  and    the_tab.EVENT_CLASSIFIER_REF is not null
  and    not exists (
             select null
             from   SDD_CLA foreign_tab
             where  the_tab.EVENT_CLASSIFIER_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4841, action);
  end loop;
  return is_ok;
end FK_EVS_TO_EVC;
/
create or replace function SDD_EVT_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_EVT_cur is
    select *
    from   i$SDD_EVT the_tab
    where  the_tab.irid=SDD_EVT_ver.irid
    and    the_tab.ivid=SDD_EVT_ver.ivid;
  SDD_EVT_rec SDD_EVT_cur%ROWTYPE;
  cursor SDD_FUNEVT_cur1 is
    select *
    from i$SDD_FUNEVT the_tab
    where the_tab.parent_ivid=SDD_EVT_ver.ivid;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_EVT_cur;
  fetch SDD_EVT_cur into SDD_EVT_rec;
  close SDD_EVT_cur;
  insert into i$SDD_EVT
  values (
    SDD_EVT_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_EVT_rec.TYPES
   ,SDD_EVT_rec.ELEMENT_TYPE_NAME
   ,SDD_EVT_rec.DATE_CREATED
   ,SDD_EVT_rec.CREATED_BY
   ,SDD_EVT_rec.DATE_CHANGED
   ,SDD_EVT_rec.CHANGED_BY
   ,SDD_EVT_rec.NOTM
   ,SDD_EVT_rec.NAME
   ,SDD_EVT_rec.EVENT_TYPE
   ,SDD_EVT_rec.ON_CONDITION
   ,SDD_EVT_rec.DATE_OF_EVENT
   ,SDD_EVT_rec.TIME
   ,SDD_EVT_rec.FREQUENCY
   ,SDD_EVT_rec.UNIT_OF_FREQUENCY
   ,SDD_EVT_rec.ENTITY_REF
   ,SDD_EVT_rec.ATTRIBUTE_REF
   ,SDD_EVT_rec.SYSTEM_DESCRIPTION
   ,SDD_EVT_rec.ICON_FILE
   ,SDD_EVT_rec.SYSTEM_CREATED_FLAG
   ,SDD_EVT_rec.EXPORT_ID
   ,SDD_EVT_rec.IMAGE_FILE
   ,SDD_EVT_rec.SOUND_FILE
   ,SDD_EVT_rec.VIDEO_FILE
   ,SDD_EVT_rec.EXECUTION_STRING
   ,SDD_EVT_rec.USRX0
   ,SDD_EVT_rec.USRX1
   ,SDD_EVT_rec.USRX2
   ,SDD_EVT_rec.USRX3
   ,SDD_EVT_rec.USRX4
   ,SDD_EVT_rec.USRX5
   ,SDD_EVT_rec.USRX6
   ,SDD_EVT_rec.USRX7
   ,SDD_EVT_rec.USRX8
   ,SDD_EVT_rec.USRX9
   ,SDD_EVT_rec.USRX10
   ,SDD_EVT_rec.USRX11
   ,SDD_EVT_rec.USRX12
   ,SDD_EVT_rec.USRX13
   ,SDD_EVT_rec.USRX14
   ,SDD_EVT_rec.USRX15
   ,SDD_EVT_rec.USRX16
   ,SDD_EVT_rec.USRX17
   ,SDD_EVT_rec.USRX18
   ,SDD_EVT_rec.USRX19
  );
  jr_reg_ver.vercopy_dependencies(SDD_EVT_ver.irid, SDD_EVT_ver.ivid, new_ivid, null, copy_dependencies);
  for SDD_FUNEVT_rec1 in SDD_FUNEVT_cur1 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_FUNEVT
    values (
       SDD_FUNEVT_rec1.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_FUNEVT_rec1.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_FUNEVT_rec1.TYPES
     , SDD_FUNEVT_rec1.ELEMENT_TYPE_NAME
     , SDD_FUNEVT_rec1.DATE_CREATED
     , SDD_FUNEVT_rec1.CREATED_BY
     , SDD_FUNEVT_rec1.DATE_CHANGED
     , SDD_FUNEVT_rec1.CHANGED_BY
     , SDD_FUNEVT_rec1.NOTM
     , SDD_FUNEVT_rec1.TRIGGERING_FUNCTION_REF
     , SDD_FUNEVT_rec1.TRIGGERING_EVENT_REF
     , SDD_FUNEVT_rec1.TRIGGERED_FUNCTION_REF
     , SDD_FUNEVT_rec1.TRIGGERED_EVENT_REF
     , SDD_FUNEVT_rec1.PRIMARY_EVENT_FLAG
     , SDD_FUNEVT_rec1.EVENT_TRIGGER_BY
     , SDD_FUNEVT_rec1.EVENT_TRIGGER_OF
     , SDD_FUNEVT_rec1.USRX0
     , SDD_FUNEVT_rec1.USRX1
     , SDD_FUNEVT_rec1.USRX2
     , SDD_FUNEVT_rec1.USRX3
     , SDD_FUNEVT_rec1.USRX4
     , SDD_FUNEVT_rec1.USRX5
     , SDD_FUNEVT_rec1.USRX6
     , SDD_FUNEVT_rec1.USRX7
     , SDD_FUNEVT_rec1.USRX8
     , SDD_FUNEVT_rec1.USRX9
     , SDD_FUNEVT_rec1.USRX10
     , SDD_FUNEVT_rec1.USRX11
     , SDD_FUNEVT_rec1.USRX12
     , SDD_FUNEVT_rec1.USRX13
     , SDD_FUNEVT_rec1.USRX14
     , SDD_FUNEVT_rec1.USRX15
     , SDD_FUNEVT_rec1.USRX16
     , SDD_FUNEVT_rec1.USRX17
     , SDD_FUNEVT_rec1.USRX18
     , SDD_FUNEVT_rec1.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_FUNEVT_rec1.irid, SDD_FUNEVT_rec1.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  jr_reg_ver.vercopy_dependent_objects(SDD_EVT_ver.ivid, new_ivid);
  return new_ivid;
end SDD_EVT_ver;
/
create or replace function PK_SDD_EVT (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_EVT the_tab_new, SDD_EVT the_tab_old
  where  the_tab_new.ivid = PK_SDD_EVT.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_EVT.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_EVT;
/
create or replace function FK_EVT_TO_ATT (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ATTRIBUTE_REF ref_value
  from   i$SDD_EVT the_tab
  where  the_tab.ivid = FK_EVT_TO_ATT.object_ivid
  and    the_tab.ATTRIBUTE_REF is not null
  and    not exists (
             select null
             from   SDD_ATT foreign_tab
             where  the_tab.ATTRIBUTE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5010, action);
  end loop;
  return is_ok;
end FK_EVT_TO_ATT;
/
create or replace function FK_EVT_TO_ENT (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ENTITY_REF ref_value
  from   i$SDD_EVT the_tab
  where  the_tab.ivid = FK_EVT_TO_ENT.object_ivid
  and    the_tab.ENTITY_REF is not null
  and    not exists (
             select null
             from   SDD_ENT foreign_tab
             where  the_tab.ENTITY_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5002, action);
  end loop;
  return is_ok;
end FK_EVT_TO_ENT;
/
create or replace function FK_DFL_TO_EXT2_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_DFL child_tab
  where  child_tab.EXTERNAL_DEST_REF=FK_DFL_TO_EXT2_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_DFL child_tab, i$sdd_object_versions o
    where  child_tab.EXTERNAL_DEST_REF=FK_DFL_TO_EXT2_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_DFL_TO_EXT2_d;
/
create or replace function SDD_EXT_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_EXT_cur is
    select *
    from   i$SDD_EXT the_tab
    where  the_tab.irid=SDD_EXT_ver.irid
    and    the_tab.ivid=SDD_EXT_ver.ivid;
  SDD_EXT_rec SDD_EXT_cur%ROWTYPE;
  cursor SDD_DFL_cur1 is
    select *
    from i$SDD_DFL the_tab
    where the_tab.parent_ivid=SDD_EXT_ver.ivid;
  cursor SDD_DFLATT_cur2 is
    select *
    from i$SDD_DFLATT the_tab
    where the_tab.parent_ivid=SDD_EXT_ver.ivid;
  cursor SDD_DFLDIT_cur3 is
    select *
    from i$SDD_DFLDIT the_tab
    where the_tab.parent_ivid=SDD_EXT_ver.ivid;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_EXT_cur;
  fetch SDD_EXT_cur into SDD_EXT_rec;
  close SDD_EXT_cur;
  insert into i$SDD_EXT
  values (
    SDD_EXT_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_EXT_rec.TYPES
   ,SDD_EXT_rec.ELEMENT_TYPE_NAME
   ,SDD_EXT_rec.DATE_CREATED
   ,SDD_EXT_rec.CREATED_BY
   ,SDD_EXT_rec.DATE_CHANGED
   ,SDD_EXT_rec.CHANGED_BY
   ,SDD_EXT_rec.NOTM
   ,SDD_EXT_rec.NAME
   ,SDD_EXT_rec.SHORT_IDENTIFIER
   ,SDD_EXT_rec.BUSINESS_UNIT_REF
   ,SDD_EXT_rec.ENTITY_REF
   ,SDD_EXT_rec.REMARK
   ,SDD_EXT_rec.USRX0
   ,SDD_EXT_rec.USRX1
   ,SDD_EXT_rec.USRX2
   ,SDD_EXT_rec.USRX3
   ,SDD_EXT_rec.USRX4
   ,SDD_EXT_rec.USRX5
   ,SDD_EXT_rec.USRX6
   ,SDD_EXT_rec.USRX7
   ,SDD_EXT_rec.USRX8
   ,SDD_EXT_rec.USRX9
   ,SDD_EXT_rec.USRX10
   ,SDD_EXT_rec.USRX11
   ,SDD_EXT_rec.USRX12
   ,SDD_EXT_rec.USRX13
   ,SDD_EXT_rec.USRX14
   ,SDD_EXT_rec.USRX15
   ,SDD_EXT_rec.USRX16
   ,SDD_EXT_rec.USRX17
   ,SDD_EXT_rec.USRX18
   ,SDD_EXT_rec.USRX19
  );
  jr_reg_ver.vercopy_dependencies(SDD_EXT_ver.irid, SDD_EXT_ver.ivid, new_ivid, null, copy_dependencies);
  for SDD_DFL_rec1 in SDD_DFL_cur1 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DFL
    values (
       SDD_DFL_rec1.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DFL_rec1.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DFL_rec1.TYPES
     , SDD_DFL_rec1.ELEMENT_TYPE_NAME
     , SDD_DFL_rec1.DATE_CREATED
     , SDD_DFL_rec1.CREATED_BY
     , SDD_DFL_rec1.DATE_CHANGED
     , SDD_DFL_rec1.CHANGED_BY
     , SDD_DFL_rec1.NOTM
     , SDD_DFL_rec1.FUNCTION_SOURCE_REF
     , SDD_DFL_rec1.DATASTORE_SOURCE_REF
     , SDD_DFL_rec1.EXTERNAL_SOURCE_REF
     , SDD_DFL_rec1.NAME
     , SDD_DFL_rec1.CLASSIFICATION
     , SDD_DFL_rec1.DESCRIPTION
     , SDD_DFL_rec1.FUNCTION_DEST_REF
     , SDD_DFL_rec1.DATASTORE_DEST_REF
     , SDD_DFL_rec1.EXTERNAL_DEST_REF
     , SDD_DFL_rec1.ACTIVATE_FLOW_FLAG
     , SDD_DFL_rec1.AND_OR_FLAG
     , SDD_DFL_rec1.BPR_USE_IN_GENERATE_FLAG
     , SDD_DFL_rec1.CRITICAL_PATH_FLAG
     , SDD_DFL_rec1.CPA_START_DATE
     , SDD_DFL_rec1.CPA_FINISH_DATE
     , SDD_DFL_rec1.CPA_RELATIVE_START_TIME
     , SDD_DFL_rec1.CPA_RELATIVE_FINISH_TIME
     , SDD_DFL_rec1.FLOW_PERCENT
     , SDD_DFL_rec1.FLOW_RULE
     , SDD_DFL_rec1.FLOW_TYPE
     , SDD_DFL_rec1.INVISIBLE_FLAG
     , SDD_DFL_rec1.SIGNIFICANT_AT_SOURCE
     , SDD_DFL_rec1.SIGNIFICANT_AT_DEST
     , SDD_DFL_rec1.EXPORT_ID
     , SDD_DFL_rec1.PERSON_COST_RATE
     , SDD_DFL_rec1.PERSON_COST_RATE_UNIT
     , SDD_DFL_rec1.OVERHEAD_COST_RATE
     , SDD_DFL_rec1.OVERHEAD_COST_RATE_UNIT
     , SDD_DFL_rec1.TOTAL_COST_RATE
     , SDD_DFL_rec1.DESTINATION_TYPE
     , SDD_DFL_rec1.SOURCE_TYPE
     , SDD_DFL_rec1.TOTAL_COST_RATE_UNIT
     , SDD_DFL_rec1.ADDITIONAL_COST_RATE
     , SDD_DFL_rec1.ADDITIONAL_COST_RATE_UNIT
     , SDD_DFL_rec1.PRIOR_DELAY_TIME
     , SDD_DFL_rec1.PRIOR_DELAY_TIME_UNIT
     , SDD_DFL_rec1.WORK_TIME
     , SDD_DFL_rec1.WORK_TIME_UNIT
     , SDD_DFL_rec1.QUALITY_CHECK_TIME
     , SDD_DFL_rec1.QUALITY_CHECK_TIME_UNIT
     , SDD_DFL_rec1.POST_DELAY_TIME
     , SDD_DFL_rec1.POST_DELAY_TIME_UNIT
     , SDD_DFL_rec1.TOTAL_TIME
     , SDD_DFL_rec1.TOTAL_TIME_UNIT
     , SDD_DFL_rec1.MEASURED_TIME_1
     , SDD_DFL_rec1.MEASURED_TIME_2
     , SDD_DFL_rec1.MEASURED_TIME_3
     , SDD_DFL_rec1.MEASURED_TIME_UNIT
     , SDD_DFL_rec1.FREQUENCY
     , SDD_DFL_rec1.FREQUENCY_UNIT
     , SDD_DFL_rec1.QUALITY_PERCENT
     , SDD_DFL_rec1.VALUE_ADDED
     , SDD_DFL_rec1.RESOURCE_REQUIRED_1
     , SDD_DFL_rec1.RESOURCE_REQUIRED_2
     , SDD_DFL_rec1.RESOURCE_REQUIRED_3
     , SDD_DFL_rec1.RESOURCE_REQUIRED_4
     , SDD_DFL_rec1.ICON_FILE
     , SDD_DFL_rec1.IMAGE_FILE
     , SDD_DFL_rec1.SOUND_FILE
     , SDD_DFL_rec1.VIDEO_FILE
     , SDD_DFL_rec1.EXECUTION_STRING
     , SDD_DFL_rec1.NOTE_TYPE
     , SDD_DFL_rec1.NOTE_TEXT
     , SDD_DFL_rec1.NOTE_PICTURE_FILE
     , SDD_DFL_rec1.USRX0
     , SDD_DFL_rec1.USRX1
     , SDD_DFL_rec1.USRX2
     , SDD_DFL_rec1.USRX3
     , SDD_DFL_rec1.USRX4
     , SDD_DFL_rec1.USRX5
     , SDD_DFL_rec1.USRX6
     , SDD_DFL_rec1.USRX7
     , SDD_DFL_rec1.USRX8
     , SDD_DFL_rec1.USRX9
     , SDD_DFL_rec1.USRX10
     , SDD_DFL_rec1.USRX11
     , SDD_DFL_rec1.USRX12
     , SDD_DFL_rec1.USRX13
     , SDD_DFL_rec1.USRX14
     , SDD_DFL_rec1.USRX15
     , SDD_DFL_rec1.USRX16
     , SDD_DFL_rec1.USRX17
     , SDD_DFL_rec1.USRX18
     , SDD_DFL_rec1.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DFL_rec1.irid, SDD_DFL_rec1.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_DFLATT_rec2 in SDD_DFLATT_cur2 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DFLATT
    values (
       SDD_DFLATT_rec2.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DFLATT_rec2.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DFLATT_rec2.TYPES
     , SDD_DFLATT_rec2.ELEMENT_TYPE_NAME
     , SDD_DFLATT_rec2.DATE_CREATED
     , SDD_DFLATT_rec2.CREATED_BY
     , SDD_DFLATT_rec2.DATE_CHANGED
     , SDD_DFLATT_rec2.CHANGED_BY
     , SDD_DFLATT_rec2.NOTM
     , SDD_DFLATT_rec2.DATAFLOW_REF
     , SDD_DFLATT_rec2.ATTRIBUTE_REF
     , SDD_DFLATT_rec2.ENTITY_REFERENCE
     , SDD_DFLATT_rec2.USRX0
     , SDD_DFLATT_rec2.USRX1
     , SDD_DFLATT_rec2.USRX2
     , SDD_DFLATT_rec2.USRX3
     , SDD_DFLATT_rec2.USRX4
     , SDD_DFLATT_rec2.USRX5
     , SDD_DFLATT_rec2.USRX6
     , SDD_DFLATT_rec2.USRX7
     , SDD_DFLATT_rec2.USRX8
     , SDD_DFLATT_rec2.USRX9
     , SDD_DFLATT_rec2.USRX10
     , SDD_DFLATT_rec2.USRX11
     , SDD_DFLATT_rec2.USRX12
     , SDD_DFLATT_rec2.USRX13
     , SDD_DFLATT_rec2.USRX14
     , SDD_DFLATT_rec2.USRX15
     , SDD_DFLATT_rec2.USRX16
     , SDD_DFLATT_rec2.USRX17
     , SDD_DFLATT_rec2.USRX18
     , SDD_DFLATT_rec2.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DFLATT_rec2.irid, SDD_DFLATT_rec2.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_DFLDIT_rec3 in SDD_DFLDIT_cur3 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DFLDIT
    values (
       SDD_DFLDIT_rec3.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DFLDIT_rec3.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DFLDIT_rec3.TYPES
     , SDD_DFLDIT_rec3.ELEMENT_TYPE_NAME
     , SDD_DFLDIT_rec3.DATE_CREATED
     , SDD_DFLDIT_rec3.CREATED_BY
     , SDD_DFLDIT_rec3.DATE_CHANGED
     , SDD_DFLDIT_rec3.CHANGED_BY
     , SDD_DFLDIT_rec3.NOTM
     , SDD_DFLDIT_rec3.DATAFLOW_REF
     , SDD_DFLDIT_rec3.DATA_ITEM_REF
     , SDD_DFLDIT_rec3.USRX0
     , SDD_DFLDIT_rec3.USRX1
     , SDD_DFLDIT_rec3.USRX2
     , SDD_DFLDIT_rec3.USRX3
     , SDD_DFLDIT_rec3.USRX4
     , SDD_DFLDIT_rec3.USRX5
     , SDD_DFLDIT_rec3.USRX6
     , SDD_DFLDIT_rec3.USRX7
     , SDD_DFLDIT_rec3.USRX8
     , SDD_DFLDIT_rec3.USRX9
     , SDD_DFLDIT_rec3.USRX10
     , SDD_DFLDIT_rec3.USRX11
     , SDD_DFLDIT_rec3.USRX12
     , SDD_DFLDIT_rec3.USRX13
     , SDD_DFLDIT_rec3.USRX14
     , SDD_DFLDIT_rec3.USRX15
     , SDD_DFLDIT_rec3.USRX16
     , SDD_DFLDIT_rec3.USRX17
     , SDD_DFLDIT_rec3.USRX18
     , SDD_DFLDIT_rec3.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DFLDIT_rec3.irid, SDD_DFLDIT_rec3.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  jr_reg_ver.vercopy_dependent_objects(SDD_EXT_ver.ivid, new_ivid);
  return new_ivid;
end SDD_EXT_ver;
/
create or replace function PK_SDD_EXT (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_EXT the_tab_new, SDD_EXT the_tab_old
  where  the_tab_new.ivid = PK_SDD_EXT.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_EXT.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_EXT;
/
create or replace function FK_EXT_TO_BUN (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.BUSINESS_UNIT_REF ref_value
  from   i$SDD_EXT the_tab
  where  the_tab.ivid = FK_EXT_TO_BUN.object_ivid
  and    the_tab.BUSINESS_UNIT_REF is not null
  and    not exists (
             select null
             from   SDD_BUN foreign_tab
             where  the_tab.BUSINESS_UNIT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5005, action);
  end loop;
  return is_ok;
end FK_EXT_TO_BUN;
/
create or replace function FK_EXT_TO_ENT (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ENTITY_REF ref_value
  from   i$SDD_EXT the_tab
  where  the_tab.ivid = FK_EXT_TO_ENT.object_ivid
  and    the_tab.ENTITY_REF is not null
  and    not exists (
             select null
             from   SDD_ENT foreign_tab
             where  the_tab.ENTITY_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5002, action);
  end loop;
  return is_ok;
end FK_EXT_TO_ENT;
/
create or replace function FK_TAB_RFI_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_TAB child_tab
  where  child_tab.RECORD_FILE_REF=FK_TAB_RFI_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_TAB child_tab, i$sdd_object_versions o
    where  child_tab.RECORD_FILE_REF=FK_TAB_RFI_d.IRID
    and    child_tab.ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_TAB_RFI_d;
/
create or replace function SDD_FIL_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_FIL_cur is
    select *
    from   i$SDD_FIL the_tab
    where  the_tab.irid=SDD_FIL_ver.irid
    and    the_tab.ivid=SDD_FIL_ver.ivid;
  SDD_FIL_rec SDD_FIL_cur%ROWTYPE;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_FIL_cur;
  fetch SDD_FIL_cur into SDD_FIL_rec;
  close SDD_FIL_cur;
  insert into i$SDD_FIL
  values (
    SDD_FIL_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_FIL_rec.TYPES
   ,SDD_FIL_rec.ELEMENT_TYPE_NAME
   ,SDD_FIL_rec.DATE_CREATED
   ,SDD_FIL_rec.CREATED_BY
   ,SDD_FIL_rec.DATE_CHANGED
   ,SDD_FIL_rec.CHANGED_BY
   ,SDD_FIL_rec.NOTM
   ,SDD_FIL_rec.NAME
   ,SDD_FIL_rec.FULL_PATHNAME
   ,SDD_FIL_rec.LANGUAGE_REF
   ,SDD_FIL_rec.FILE_TYPE
   ,SDD_FIL_rec.ORGANIZATION
   ,SDD_FIL_rec.ACCESS_METHOD
   ,SDD_FIL_rec.STORAGE_MEDIA
   ,SDD_FIL_rec.BLOCK_SIZE
   ,SDD_FIL_rec.CLUSTER_SIZE
   ,SDD_FIL_rec.FILE_SIZE
   ,SDD_FIL_rec.UNIT
   ,SDD_FIL_rec.REMARK
   ,SDD_FIL_rec.OS_FILE_TYPE
   ,SDD_FIL_rec.USRX0
   ,SDD_FIL_rec.USRX1
   ,SDD_FIL_rec.USRX2
   ,SDD_FIL_rec.USRX3
   ,SDD_FIL_rec.USRX4
   ,SDD_FIL_rec.USRX5
   ,SDD_FIL_rec.USRX6
   ,SDD_FIL_rec.USRX7
   ,SDD_FIL_rec.USRX8
   ,SDD_FIL_rec.USRX9
   ,SDD_FIL_rec.USRX10
   ,SDD_FIL_rec.USRX11
   ,SDD_FIL_rec.USRX12
   ,SDD_FIL_rec.USRX13
   ,SDD_FIL_rec.USRX14
   ,SDD_FIL_rec.USRX15
   ,SDD_FIL_rec.USRX16
   ,SDD_FIL_rec.USRX17
   ,SDD_FIL_rec.USRX18
   ,SDD_FIL_rec.USRX19
  );
  jr_reg_ver.vercopy_dependencies(SDD_FIL_ver.irid, SDD_FIL_ver.ivid, new_ivid, null, copy_dependencies);
  jr_reg_ver.vercopy_dependent_objects(SDD_FIL_ver.ivid, new_ivid);
  return new_ivid;
end SDD_FIL_ver;
/
create or replace function PK_SDD_FIL (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_FIL the_tab_new, SDD_FIL the_tab_old
  where  the_tab_new.ivid = PK_SDD_FIL.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_FIL.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_FIL;
/
create or replace function FK_FIL_TO_LAN (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.LANGUAGE_REF ref_value
  from   i$SDD_FIL the_tab
  where  the_tab.ivid = FK_FIL_TO_LAN.object_ivid
  and    the_tab.LANGUAGE_REF is not null
  and    not exists (
             select null
             from   SDD_LAN foreign_tab
             where  the_tab.LANGUAGE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4996, action);
  end loop;
  return is_ok;
end FK_FIL_TO_LAN;
/
create or replace function SDD_FILES_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_FILES_cur is
    select *
    from   i$SDD_FILES the_tab
    where  the_tab.irid=SDD_FILES_ver.irid
    and    the_tab.ivid=SDD_FILES_ver.ivid;
  SDD_FILES_rec SDD_FILES_cur%ROWTYPE;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_FILES_cur;
  fetch SDD_FILES_cur into SDD_FILES_rec;
  close SDD_FILES_cur;
  insert into i$SDD_FILES
  values (
    SDD_FILES_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_FILES_rec.TYPES
   ,SDD_FILES_rec.ELEMENT_TYPE_NAME
   ,SDD_FILES_rec.DATE_CREATED
   ,SDD_FILES_rec.CREATED_BY
   ,SDD_FILES_rec.DATE_CHANGED
   ,SDD_FILES_rec.CHANGED_BY
   ,SDD_FILES_rec.NOTM
   ,SDD_FILES_rec.FILE_SIZE
   ,SDD_FILES_rec.NAME
   ,SDD_FILES_rec.KIND
   ,SDD_FILES_rec.CRC
   ,SDD_FILES_rec.OWNER
   ,SDD_FILES_rec.TEXT_FORMAT
   ,SDD_FILES_rec.OS_TIMESTAMP
   ,SDD_FILES_rec.OS_PRIVILEGES
   ,SDD_FILES_rec.SHORT_DESCRIPTION
   ,SDD_FILES_rec.CONTENTS_BLOB
  );
  jr_reg_ver.vercopy_dependencies(SDD_FILES_ver.irid, SDD_FILES_ver.ivid, new_ivid, null, copy_dependencies);
  jr_reg_ver.vercopy_dependent_objects(SDD_FILES_ver.ivid, new_ivid);
  return new_ivid;
end SDD_FILES_ver;
/
create or replace function PK_SDD_FILES (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_FILES the_tab_new, SDD_FILES the_tab_old
  where  the_tab_new.ivid = PK_SDD_FILES.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_FILES.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_FILES;
/
create or replace function PK_SDD_FILPAC (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_FILPAC the_tab_new, SDD_FILPAC the_tab_old
  where  the_tab_new.ivid = PK_SDD_FILPAC.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_FILPAC.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_FILPAC;
/
create or replace function FK_FILPAC_TO_FILES (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.PRIMARY_ACCESS_FILE_REF ref_value
  from   i$SDD_FILPAC the_tab
  where  the_tab.ivid = FK_FILPAC_TO_FILES.object_ivid
  and    the_tab.PRIMARY_ACCESS_FILE_REF is not null
  and    not exists (
             select null
             from   SDD_FILES foreign_tab
             where  the_tab.PRIMARY_ACCESS_FILE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4819, action);
  end loop;
  return is_ok;
end FK_FILPAC_TO_FILES;
/
create or replace function SDD_FOLDERS_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_FOLDERS_cur is
    select *
    from   i$SDD_FOLDERS the_tab
    where  the_tab.irid=SDD_FOLDERS_ver.irid
    and    the_tab.ivid=SDD_FOLDERS_ver.ivid;
  SDD_FOLDERS_rec SDD_FOLDERS_cur%ROWTYPE;
  cursor SDD_FOLDER_MEMBERS_cur1 is
    select *
    from i$SDD_FOLDER_MEMBERS the_tab
    where the_tab.parent_ivid=SDD_FOLDERS_ver.ivid;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_FOLDERS_cur;
  fetch SDD_FOLDERS_cur into SDD_FOLDERS_rec;
  close SDD_FOLDERS_cur;
  insert into i$SDD_FOLDERS
  values (
    SDD_FOLDERS_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_FOLDERS_rec.TYPES
   ,SDD_FOLDERS_rec.ELEMENT_TYPE_NAME
   ,SDD_FOLDERS_rec.DATE_CREATED
   ,SDD_FOLDERS_rec.CREATED_BY
   ,SDD_FOLDERS_rec.DATE_CHANGED
   ,SDD_FOLDERS_rec.CHANGED_BY
   ,SDD_FOLDERS_rec.NOTM
   ,SDD_FOLDERS_rec.OWNING_USER
   ,SDD_FOLDERS_rec.CONTAINER_SUBTYPE
   ,SDD_FOLDERS_rec.AUTHORITY
   ,SDD_FOLDERS_rec.CONSTRAINTS
   ,SDD_FOLDERS_rec.DATAWAREHOUSE_FLAG
   ,SDD_FOLDERS_rec.PRIORITIES
   ,SDD_FOLDERS_rec.REMARK
   ,SDD_FOLDERS_rec.GENERATE_CLASSES_FLAG
   ,SDD_FOLDERS_rec.USRX0
   ,SDD_FOLDERS_rec.USRX1
   ,SDD_FOLDERS_rec.USRX10
   ,SDD_FOLDERS_rec.USRX11
   ,SDD_FOLDERS_rec.USRX12
   ,SDD_FOLDERS_rec.USRX13
   ,SDD_FOLDERS_rec.USRX14
   ,SDD_FOLDERS_rec.USRX15
   ,SDD_FOLDERS_rec.USRX16
   ,SDD_FOLDERS_rec.USRX17
   ,SDD_FOLDERS_rec.USRX18
   ,SDD_FOLDERS_rec.USRX19
   ,SDD_FOLDERS_rec.USRX2
   ,SDD_FOLDERS_rec.USRX3
   ,SDD_FOLDERS_rec.USRX4
   ,SDD_FOLDERS_rec.USRX5
   ,SDD_FOLDERS_rec.USRX6
   ,SDD_FOLDERS_rec.USRX7
   ,SDD_FOLDERS_rec.USRX8
   ,SDD_FOLDERS_rec.USRX9
   ,SDD_FOLDERS_rec.NAME
   ,SDD_FOLDERS_rec.APPLICATION_TYPE
   ,SDD_FOLDERS_rec.TYPE
   ,SDD_FOLDERS_rec.CLASSIFIER_REF
   ,SDD_FOLDERS_rec.EXTERNAL_FLAG
   ,SDD_FOLDERS_rec.INSTANTIABLE_FLAG
   ,SDD_FOLDERS_rec.LANGUAGE_REF
   ,SDD_FOLDERS_rec.AUTHOR
   ,SDD_FOLDERS_rec.CODING_STANDARD_REF
   ,SDD_FOLDERS_rec.IMPLEMENTATION_TARGET
   ,SDD_FOLDERS_rec.DISPLAY_TITLE
   ,SDD_FOLDERS_rec.TRANSFORMER_STANDARD_REF
   ,SDD_FOLDERS_rec.ICON_FILE_REF
   ,SDD_FOLDERS_rec.DEVELOPMENT_LEVEL
   ,SDD_FOLDERS_rec.OS_TIMESTAMP
   ,SDD_FOLDERS_rec.ROOT_FLAG
   ,SDD_FOLDERS_rec.O8I_TARGET_FLAG
   ,SDD_FOLDERS_rec.VISIBROKER_TARGET_FLAG
   ,SDD_FOLDERS_rec.EJB_TARGET_FLAG
   ,SDD_FOLDERS_rec.GENERATE_IDL_FLAG
   ,SDD_FOLDERS_rec.GENERATE_METADATA_FLAG
   ,SDD_FOLDERS_rec.METADATA_CLASS_NAME
   ,SDD_FOLDERS_rec.SYSTEM_ELEMENT_FLAG
  );
  jr_reg_ver.vercopy_dependencies(SDD_FOLDERS_ver.irid, SDD_FOLDERS_ver.ivid, new_ivid, null, copy_dependencies);
  for SDD_FOLDER_MEMBERS_rec1 in SDD_FOLDER_MEMBERS_cur1 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_FOLDER_MEMBERS
    values (
       SDD_FOLDER_MEMBERS_rec1.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_FOLDER_MEMBERS_rec1.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_FOLDER_MEMBERS_rec1.TYPES
     , SDD_FOLDER_MEMBERS_rec1.DATE_CREATED
     , SDD_FOLDER_MEMBERS_rec1.CREATED_BY
     , SDD_FOLDER_MEMBERS_rec1.DATE_CHANGED
     , SDD_FOLDER_MEMBERS_rec1.CHANGED_BY
     , SDD_FOLDER_MEMBERS_rec1.NOTM
     , SDD_FOLDER_MEMBERS_rec1.FOLDER_REFERENCE
     , SDD_FOLDER_MEMBERS_rec1.MEMBER_OBJECT
     , SDD_FOLDER_MEMBERS_rec1.NAME_IN_CONTEXT
     , SDD_FOLDER_MEMBERS_rec1.OWNERSHIP_FLAG
     , SDD_FOLDER_MEMBERS_rec1.VISIBILITY
    );
  jr_reg_ver.vercopy_dependencies(SDD_FOLDER_MEMBERS_rec1.irid, SDD_FOLDER_MEMBERS_rec1.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  jr_reg_ver.vercopy_dependent_objects(SDD_FOLDERS_ver.ivid, new_ivid);
  return new_ivid;
end SDD_FOLDERS_ver;
/
create or replace function PK_SDD_FOLDERS (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_FOLDERS the_tab_new, SDD_FOLDERS the_tab_old
  where  the_tab_new.ivid = PK_SDD_FOLDERS.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_FOLDERS.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_FOLDERS;
/
create or replace function FK_CEL_TO_CLA (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.CLASSIFIER_REF ref_value
  from   i$SDD_FOLDERS the_tab
  where  the_tab.ivid = FK_CEL_TO_CLA.object_ivid
  and    the_tab.CLASSIFIER_REF is not null
  and    not exists (
             select null
             from   SDD_CLA foreign_tab
             where  the_tab.CLASSIFIER_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4841, action);
  end loop;
  return is_ok;
end FK_CEL_TO_CLA;
/
create or replace function FK_CEL_TO_COS (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.CODING_STANDARD_REF ref_value
  from   i$SDD_FOLDERS the_tab
  where  the_tab.ivid = FK_CEL_TO_COS.object_ivid
  and    the_tab.CODING_STANDARD_REF is not null
  and    not exists (
             select null
             from   SDD_PST foreign_tab
             where  the_tab.CODING_STANDARD_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5155, action);
  end loop;
  return is_ok;
end FK_CEL_TO_COS;
/
create or replace function FK_CEL_TO_FILES (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ICON_FILE_REF ref_value
  from   i$SDD_FOLDERS the_tab
  where  the_tab.ivid = FK_CEL_TO_FILES.object_ivid
  and    the_tab.ICON_FILE_REF is not null
  and    not exists (
             select null
             from   SDD_FILES foreign_tab
             where  the_tab.ICON_FILE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4819, action);
  end loop;
  return is_ok;
end FK_CEL_TO_FILES;
/
create or replace function FK_CEL_TO_LAN (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.LANGUAGE_REF ref_value
  from   i$SDD_FOLDERS the_tab
  where  the_tab.ivid = FK_CEL_TO_LAN.object_ivid
  and    the_tab.LANGUAGE_REF is not null
  and    not exists (
             select null
             from   SDD_LAN foreign_tab
             where  the_tab.LANGUAGE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4996, action);
  end loop;
  return is_ok;
end FK_CEL_TO_LAN;
/
create or replace function FK_CEL_TO_TRS (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.TRANSFORMER_STANDARD_REF ref_value
  from   i$SDD_FOLDERS the_tab
  where  the_tab.ivid = FK_CEL_TO_TRS.object_ivid
  and    the_tab.TRANSFORMER_STANDARD_REF is not null
  and    not exists (
             select null
             from   SDD_PST foreign_tab
             where  the_tab.TRANSFORMER_STANDARD_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5155, action);
  end loop;
  return is_ok;
end FK_CEL_TO_TRS;
/
create or replace function PK_FOLDER_MEMBERS (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_FOLDER_MEMBERS the_tab_new, SDD_FOLDER_MEMBERS the_tab_old
  where  the_tab_new.ivid = PK_FOLDER_MEMBERS.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_FOLDER_MEMBERS.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_FOLDER_MEMBERS;
/
create or replace function SDD_FOLDER_MEMBER_OBJ_FK (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.MEMBER_OBJECT ref_value
  from   i$SDD_FOLDER_MEMBERS the_tab
  where  the_tab.ivid = SDD_FOLDER_MEMBER_OBJ_FK.object_ivid
  and    the_tab.MEMBER_OBJECT is not null
  and    not exists (
             select null
             from   SDD_OBJECT_VERSIONS foreign_tab
             where  the_tab.MEMBER_OBJECT = foreign_tab.IVID
             );
  is_ok boolean := true;
begin
/*
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 384781276385882128752423040909330489, action);
  end loop;
*/
  return is_ok;
end SDD_FOLDER_MEMBER_OBJ_FK;
/
create or replace function PK_SDD_FSE (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_FSE the_tab_new, SDD_FSE the_tab_old
  where  the_tab_new.ivid = PK_SDD_FSE.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_FSE.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_FSE;
/
create or replace function FK_FSE_TO_FILES (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.PRIMARY_ACCESS_FILE_REF ref_value
  from   i$SDD_FSE the_tab
  where  the_tab.ivid = FK_FSE_TO_FILES.object_ivid
  and    the_tab.PRIMARY_ACCESS_FILE_REF is not null
  and    not exists (
             select null
             from   SDD_FILES foreign_tab
             where  the_tab.PRIMARY_ACCESS_FILE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4819, action);
  end loop;
  return is_ok;
end FK_FSE_TO_FILES;
/
create or replace function FK_DFL_TO_FUN2_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_DFL child_tab
  where  child_tab.FUNCTION_DEST_REF=FK_DFL_TO_FUN2_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_DFL child_tab, i$sdd_object_versions o
    where  child_tab.FUNCTION_DEST_REF=FK_DFL_TO_FUN2_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_DFL_TO_FUN2_d;
/
create or replace function FK_FUN_TO_FUN_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_FUN child_tab
  where  child_tab.PARENT_REF=FK_FUN_TO_FUN_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_FUN child_tab, i$sdd_object_versions o
    where  child_tab.PARENT_REF=FK_FUN_TO_FUN_d.IRID
    and    child_tab.ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_FUN_TO_FUN_d;
/
create or replace function FK_FUN_TO_FUN2_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_FUN child_tab
  where  child_tab.COMMON_FUNCTION_REF=FK_FUN_TO_FUN2_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_FUN child_tab, i$sdd_object_versions o
    where  child_tab.COMMON_FUNCTION_REF=FK_FUN_TO_FUN2_d.IRID
    and    child_tab.ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_FUN_TO_FUN2_d;
/
create or replace function FK_FUNEVT_TO_FUN_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_FUNEVT child_tab
  where  child_tab.TRIGGERING_FUNCTION_REF=FK_FUNEVT_TO_FUN_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_FUNEVT child_tab, i$sdd_object_versions o
    where  child_tab.TRIGGERING_FUNCTION_REF=FK_FUNEVT_TO_FUN_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_FUNEVT_TO_FUN_d;
/
create or replace function FK_MODFUN_TO_FUN_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_MODFUN child_tab
  where  child_tab.FUNCTION_REF=FK_MODFUN_TO_FUN_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_MODFUN child_tab, i$sdd_object_versions o
    where  child_tab.FUNCTION_REF=FK_MODFUN_TO_FUN_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_MODFUN_TO_FUN_d;
/
create or replace function SDD_FUN_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_FUN_cur is
    select *
    from   i$SDD_FUN the_tab
    where  the_tab.irid=SDD_FUN_ver.irid
    and    the_tab.ivid=SDD_FUN_ver.ivid;
  SDD_FUN_rec SDD_FUN_cur%ROWTYPE;
  cursor SDD_DFL_cur1 is
    select *
    from i$SDD_DFL the_tab
    where the_tab.parent_ivid=SDD_FUN_ver.ivid;
  cursor SDD_DFLATT_cur2 is
    select *
    from i$SDD_DFLATT the_tab
    where the_tab.parent_ivid=SDD_FUN_ver.ivid;
  cursor SDD_DFLDIT_cur3 is
    select *
    from i$SDD_DFLDIT the_tab
    where the_tab.parent_ivid=SDD_FUN_ver.ivid;
  cursor SDD_FUNATT_cur4 is
    select *
    from i$SDD_FUNATT the_tab
    where the_tab.parent_ivid=SDD_FUN_ver.ivid;
  cursor SDD_FUNBUN_cur5 is
    select *
    from i$SDD_FUNBUN the_tab
    where the_tab.parent_ivid=SDD_FUN_ver.ivid;
  cursor SDD_FUNENT_cur6 is
    select *
    from i$SDD_FUNENT the_tab
    where the_tab.parent_ivid=SDD_FUN_ver.ivid;
  cursor SDD_FUNEVT_cur7 is
    select *
    from i$SDD_FUNEVT the_tab
    where the_tab.parent_ivid=SDD_FUN_ver.ivid;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_FUN_cur;
  fetch SDD_FUN_cur into SDD_FUN_rec;
  close SDD_FUN_cur;
  insert into i$SDD_FUN
  values (
    SDD_FUN_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_FUN_rec.TYPES
   ,SDD_FUN_rec.ELEMENT_TYPE_NAME
   ,SDD_FUN_rec.DATE_CREATED
   ,SDD_FUN_rec.CREATED_BY
   ,SDD_FUN_rec.DATE_CHANGED
   ,SDD_FUN_rec.CHANGED_BY
   ,SDD_FUN_rec.NOTM
   ,SDD_FUN_rec.FUNCTION_LABEL
   ,SDD_FUN_rec.SHORT_DEFINITION
   ,SDD_FUN_rec.COMMON_FUNCTION_REF
   ,SDD_FUN_rec.PARENT_REF
   ,SDD_FUN_rec.SEQUENCE_IN_PARENT
   ,SDD_FUN_rec.ELEMENTARY_FLAG
   ,SDD_FUN_rec.FREQUENCY
   ,SDD_FUN_rec.FREQUENCY_UNIT
   ,SDD_FUN_rec.RESPONSE_NEEDED
   ,SDD_FUN_rec.FUNCTION_TYPE
   ,SDD_FUN_rec.TO_BE_AUTOMATED_FLAG
   ,SDD_FUN_rec.BPR_GENERATE_FLAG
   ,SDD_FUN_rec.CRITICAL_PATH_FLAG
   ,SDD_FUN_rec.CPA_START_DATE
   ,SDD_FUN_rec.CPA_FINISH_DATE
   ,SDD_FUN_rec.EXPORT_ID
   ,SDD_FUN_rec.CPA_RELATIVE_START_TIME
   ,SDD_FUN_rec.CPA_RELATIVE_FINISH_TIME
   ,SDD_FUN_rec.PERSON_COST_RATE
   ,SDD_FUN_rec.PERSON_COST_RATE_UNIT
   ,SDD_FUN_rec.OVERHEAD_COST_RATE
   ,SDD_FUN_rec.OVERHEAD_COST_RATE_UNIT
   ,SDD_FUN_rec.TOTAL_COST_RATE
   ,SDD_FUN_rec.TOTAL_COST_RATE_UNIT
   ,SDD_FUN_rec.ADDITIONAL_COST_RATE
   ,SDD_FUN_rec.ADDITIONAL_COST_RATE_UNIT
   ,SDD_FUN_rec.PRIOR_DELAY_TIME
   ,SDD_FUN_rec.PRIOR_DELAY_TIME_UNIT
   ,SDD_FUN_rec.WORK_TIME
   ,SDD_FUN_rec.WORK_TIME_UNIT
   ,SDD_FUN_rec.QUALITY_CHECK_TIME
   ,SDD_FUN_rec.QUALITY_CHECK_TIME_UNIT
   ,SDD_FUN_rec.POST_DELAY_TIME
   ,SDD_FUN_rec.POST_DELAY_TIME_UNIT
   ,SDD_FUN_rec.TOTAL_TIME
   ,SDD_FUN_rec.TOTAL_TIME_UNIT
   ,SDD_FUN_rec.MEASURED_TIME_1
   ,SDD_FUN_rec.MEASURED_TIME_2
   ,SDD_FUN_rec.MEASURED_TIME_3
   ,SDD_FUN_rec.MEASURED_TIME_UNIT
   ,SDD_FUN_rec.QUALITY_PERCENT
   ,SDD_FUN_rec.VALUE_ADDED
   ,SDD_FUN_rec.COMPETITIVE_INDEX_VALUE
   ,SDD_FUN_rec.RESOURCE_REQUIRED_1
   ,SDD_FUN_rec.RESOURCE_REQUIRED_2
   ,SDD_FUN_rec.RESOURCE_REQUIRED_3
   ,SDD_FUN_rec.RESOURCE_REQUIRED_4
   ,SDD_FUN_rec.ICON_FILE
   ,SDD_FUN_rec.IMAGE_FILE
   ,SDD_FUN_rec.SOUND_FILE
   ,SDD_FUN_rec.VIDEO_FILE
   ,SDD_FUN_rec.EXECUTION_STRING
   ,SDD_FUN_rec.NOTE_TYPE
   ,SDD_FUN_rec.NOTE_TEXT
   ,SDD_FUN_rec.NOTE_PICTURE_FILE
   ,SDD_FUN_rec.USRX0
   ,SDD_FUN_rec.USRX1
   ,SDD_FUN_rec.USRX2
   ,SDD_FUN_rec.USRX3
   ,SDD_FUN_rec.USRX4
   ,SDD_FUN_rec.USRX5
   ,SDD_FUN_rec.USRX6
   ,SDD_FUN_rec.USRX7
   ,SDD_FUN_rec.USRX8
   ,SDD_FUN_rec.USRX9
   ,SDD_FUN_rec.USRX10
   ,SDD_FUN_rec.USRX11
   ,SDD_FUN_rec.USRX12
   ,SDD_FUN_rec.USRX13
   ,SDD_FUN_rec.USRX14
   ,SDD_FUN_rec.USRX15
   ,SDD_FUN_rec.USRX16
   ,SDD_FUN_rec.USRX17
   ,SDD_FUN_rec.USRX18
   ,SDD_FUN_rec.USRX19
  );
  jr_reg_ver.vercopy_dependencies(SDD_FUN_ver.irid, SDD_FUN_ver.ivid, new_ivid, null, copy_dependencies);
  for SDD_DFL_rec1 in SDD_DFL_cur1 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DFL
    values (
       SDD_DFL_rec1.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DFL_rec1.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DFL_rec1.TYPES
     , SDD_DFL_rec1.ELEMENT_TYPE_NAME
     , SDD_DFL_rec1.DATE_CREATED
     , SDD_DFL_rec1.CREATED_BY
     , SDD_DFL_rec1.DATE_CHANGED
     , SDD_DFL_rec1.CHANGED_BY
     , SDD_DFL_rec1.NOTM
     , SDD_DFL_rec1.FUNCTION_SOURCE_REF
     , SDD_DFL_rec1.DATASTORE_SOURCE_REF
     , SDD_DFL_rec1.EXTERNAL_SOURCE_REF
     , SDD_DFL_rec1.NAME
     , SDD_DFL_rec1.CLASSIFICATION
     , SDD_DFL_rec1.DESCRIPTION
     , SDD_DFL_rec1.FUNCTION_DEST_REF
     , SDD_DFL_rec1.DATASTORE_DEST_REF
     , SDD_DFL_rec1.EXTERNAL_DEST_REF
     , SDD_DFL_rec1.ACTIVATE_FLOW_FLAG
     , SDD_DFL_rec1.AND_OR_FLAG
     , SDD_DFL_rec1.BPR_USE_IN_GENERATE_FLAG
     , SDD_DFL_rec1.CRITICAL_PATH_FLAG
     , SDD_DFL_rec1.CPA_START_DATE
     , SDD_DFL_rec1.CPA_FINISH_DATE
     , SDD_DFL_rec1.CPA_RELATIVE_START_TIME
     , SDD_DFL_rec1.CPA_RELATIVE_FINISH_TIME
     , SDD_DFL_rec1.FLOW_PERCENT
     , SDD_DFL_rec1.FLOW_RULE
     , SDD_DFL_rec1.FLOW_TYPE
     , SDD_DFL_rec1.INVISIBLE_FLAG
     , SDD_DFL_rec1.SIGNIFICANT_AT_SOURCE
     , SDD_DFL_rec1.SIGNIFICANT_AT_DEST
     , SDD_DFL_rec1.EXPORT_ID
     , SDD_DFL_rec1.PERSON_COST_RATE
     , SDD_DFL_rec1.PERSON_COST_RATE_UNIT
     , SDD_DFL_rec1.OVERHEAD_COST_RATE
     , SDD_DFL_rec1.OVERHEAD_COST_RATE_UNIT
     , SDD_DFL_rec1.TOTAL_COST_RATE
     , SDD_DFL_rec1.DESTINATION_TYPE
     , SDD_DFL_rec1.SOURCE_TYPE
     , SDD_DFL_rec1.TOTAL_COST_RATE_UNIT
     , SDD_DFL_rec1.ADDITIONAL_COST_RATE
     , SDD_DFL_rec1.ADDITIONAL_COST_RATE_UNIT
     , SDD_DFL_rec1.PRIOR_DELAY_TIME
     , SDD_DFL_rec1.PRIOR_DELAY_TIME_UNIT
     , SDD_DFL_rec1.WORK_TIME
     , SDD_DFL_rec1.WORK_TIME_UNIT
     , SDD_DFL_rec1.QUALITY_CHECK_TIME
     , SDD_DFL_rec1.QUALITY_CHECK_TIME_UNIT
     , SDD_DFL_rec1.POST_DELAY_TIME
     , SDD_DFL_rec1.POST_DELAY_TIME_UNIT
     , SDD_DFL_rec1.TOTAL_TIME
     , SDD_DFL_rec1.TOTAL_TIME_UNIT
     , SDD_DFL_rec1.MEASURED_TIME_1
     , SDD_DFL_rec1.MEASURED_TIME_2
     , SDD_DFL_rec1.MEASURED_TIME_3
     , SDD_DFL_rec1.MEASURED_TIME_UNIT
     , SDD_DFL_rec1.FREQUENCY
     , SDD_DFL_rec1.FREQUENCY_UNIT
     , SDD_DFL_rec1.QUALITY_PERCENT
     , SDD_DFL_rec1.VALUE_ADDED
     , SDD_DFL_rec1.RESOURCE_REQUIRED_1
     , SDD_DFL_rec1.RESOURCE_REQUIRED_2
     , SDD_DFL_rec1.RESOURCE_REQUIRED_3
     , SDD_DFL_rec1.RESOURCE_REQUIRED_4
     , SDD_DFL_rec1.ICON_FILE
     , SDD_DFL_rec1.IMAGE_FILE
     , SDD_DFL_rec1.SOUND_FILE
     , SDD_DFL_rec1.VIDEO_FILE
     , SDD_DFL_rec1.EXECUTION_STRING
     , SDD_DFL_rec1.NOTE_TYPE
     , SDD_DFL_rec1.NOTE_TEXT
     , SDD_DFL_rec1.NOTE_PICTURE_FILE
     , SDD_DFL_rec1.USRX0
     , SDD_DFL_rec1.USRX1
     , SDD_DFL_rec1.USRX2
     , SDD_DFL_rec1.USRX3
     , SDD_DFL_rec1.USRX4
     , SDD_DFL_rec1.USRX5
     , SDD_DFL_rec1.USRX6
     , SDD_DFL_rec1.USRX7
     , SDD_DFL_rec1.USRX8
     , SDD_DFL_rec1.USRX9
     , SDD_DFL_rec1.USRX10
     , SDD_DFL_rec1.USRX11
     , SDD_DFL_rec1.USRX12
     , SDD_DFL_rec1.USRX13
     , SDD_DFL_rec1.USRX14
     , SDD_DFL_rec1.USRX15
     , SDD_DFL_rec1.USRX16
     , SDD_DFL_rec1.USRX17
     , SDD_DFL_rec1.USRX18
     , SDD_DFL_rec1.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DFL_rec1.irid, SDD_DFL_rec1.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_DFLATT_rec2 in SDD_DFLATT_cur2 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DFLATT
    values (
       SDD_DFLATT_rec2.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DFLATT_rec2.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DFLATT_rec2.TYPES
     , SDD_DFLATT_rec2.ELEMENT_TYPE_NAME
     , SDD_DFLATT_rec2.DATE_CREATED
     , SDD_DFLATT_rec2.CREATED_BY
     , SDD_DFLATT_rec2.DATE_CHANGED
     , SDD_DFLATT_rec2.CHANGED_BY
     , SDD_DFLATT_rec2.NOTM
     , SDD_DFLATT_rec2.DATAFLOW_REF
     , SDD_DFLATT_rec2.ATTRIBUTE_REF
     , SDD_DFLATT_rec2.ENTITY_REFERENCE
     , SDD_DFLATT_rec2.USRX0
     , SDD_DFLATT_rec2.USRX1
     , SDD_DFLATT_rec2.USRX2
     , SDD_DFLATT_rec2.USRX3
     , SDD_DFLATT_rec2.USRX4
     , SDD_DFLATT_rec2.USRX5
     , SDD_DFLATT_rec2.USRX6
     , SDD_DFLATT_rec2.USRX7
     , SDD_DFLATT_rec2.USRX8
     , SDD_DFLATT_rec2.USRX9
     , SDD_DFLATT_rec2.USRX10
     , SDD_DFLATT_rec2.USRX11
     , SDD_DFLATT_rec2.USRX12
     , SDD_DFLATT_rec2.USRX13
     , SDD_DFLATT_rec2.USRX14
     , SDD_DFLATT_rec2.USRX15
     , SDD_DFLATT_rec2.USRX16
     , SDD_DFLATT_rec2.USRX17
     , SDD_DFLATT_rec2.USRX18
     , SDD_DFLATT_rec2.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DFLATT_rec2.irid, SDD_DFLATT_rec2.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_DFLDIT_rec3 in SDD_DFLDIT_cur3 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DFLDIT
    values (
       SDD_DFLDIT_rec3.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DFLDIT_rec3.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DFLDIT_rec3.TYPES
     , SDD_DFLDIT_rec3.ELEMENT_TYPE_NAME
     , SDD_DFLDIT_rec3.DATE_CREATED
     , SDD_DFLDIT_rec3.CREATED_BY
     , SDD_DFLDIT_rec3.DATE_CHANGED
     , SDD_DFLDIT_rec3.CHANGED_BY
     , SDD_DFLDIT_rec3.NOTM
     , SDD_DFLDIT_rec3.DATAFLOW_REF
     , SDD_DFLDIT_rec3.DATA_ITEM_REF
     , SDD_DFLDIT_rec3.USRX0
     , SDD_DFLDIT_rec3.USRX1
     , SDD_DFLDIT_rec3.USRX2
     , SDD_DFLDIT_rec3.USRX3
     , SDD_DFLDIT_rec3.USRX4
     , SDD_DFLDIT_rec3.USRX5
     , SDD_DFLDIT_rec3.USRX6
     , SDD_DFLDIT_rec3.USRX7
     , SDD_DFLDIT_rec3.USRX8
     , SDD_DFLDIT_rec3.USRX9
     , SDD_DFLDIT_rec3.USRX10
     , SDD_DFLDIT_rec3.USRX11
     , SDD_DFLDIT_rec3.USRX12
     , SDD_DFLDIT_rec3.USRX13
     , SDD_DFLDIT_rec3.USRX14
     , SDD_DFLDIT_rec3.USRX15
     , SDD_DFLDIT_rec3.USRX16
     , SDD_DFLDIT_rec3.USRX17
     , SDD_DFLDIT_rec3.USRX18
     , SDD_DFLDIT_rec3.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DFLDIT_rec3.irid, SDD_DFLDIT_rec3.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_FUNATT_rec4 in SDD_FUNATT_cur4 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_FUNATT
    values (
       SDD_FUNATT_rec4.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_FUNATT_rec4.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_FUNATT_rec4.TYPES
     , SDD_FUNATT_rec4.ELEMENT_TYPE_NAME
     , SDD_FUNATT_rec4.DATE_CREATED
     , SDD_FUNATT_rec4.CREATED_BY
     , SDD_FUNATT_rec4.DATE_CHANGED
     , SDD_FUNATT_rec4.CHANGED_BY
     , SDD_FUNATT_rec4.NOTM
     , SDD_FUNATT_rec4.FUNCTION_REF
     , SDD_FUNATT_rec4.ATTRIBUTE_REF
     , SDD_FUNATT_rec4.INSERT_FLAG
     , SDD_FUNATT_rec4.RETRIEVE_FLAG
     , SDD_FUNATT_rec4.UPDATE_FLAG
     , SDD_FUNATT_rec4.NULLIFY_FLAG
     , SDD_FUNATT_rec4.ARCHIVE_FLAG
     , SDD_FUNATT_rec4.USER_DEFINED_USAGE_FLAG
     , SDD_FUNATT_rec4.REMARK
     , SDD_FUNATT_rec4.FUNENT_REF
     , SDD_FUNATT_rec4.ENTITY_REFERENCE
     , SDD_FUNATT_rec4.USRX0
     , SDD_FUNATT_rec4.USRX1
     , SDD_FUNATT_rec4.USRX2
     , SDD_FUNATT_rec4.USRX3
     , SDD_FUNATT_rec4.USRX4
     , SDD_FUNATT_rec4.USRX5
     , SDD_FUNATT_rec4.USRX6
     , SDD_FUNATT_rec4.USRX7
     , SDD_FUNATT_rec4.USRX8
     , SDD_FUNATT_rec4.USRX9
     , SDD_FUNATT_rec4.USRX10
     , SDD_FUNATT_rec4.USRX11
     , SDD_FUNATT_rec4.USRX12
     , SDD_FUNATT_rec4.USRX13
     , SDD_FUNATT_rec4.USRX14
     , SDD_FUNATT_rec4.USRX15
     , SDD_FUNATT_rec4.USRX16
     , SDD_FUNATT_rec4.USRX17
     , SDD_FUNATT_rec4.USRX18
     , SDD_FUNATT_rec4.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_FUNATT_rec4.irid, SDD_FUNATT_rec4.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_FUNBUN_rec5 in SDD_FUNBUN_cur5 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_FUNBUN
    values (
       SDD_FUNBUN_rec5.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_FUNBUN_rec5.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_FUNBUN_rec5.TYPES
     , SDD_FUNBUN_rec5.ELEMENT_TYPE_NAME
     , SDD_FUNBUN_rec5.DATE_CREATED
     , SDD_FUNBUN_rec5.CREATED_BY
     , SDD_FUNBUN_rec5.DATE_CHANGED
     , SDD_FUNBUN_rec5.CHANGED_BY
     , SDD_FUNBUN_rec5.NOTM
     , SDD_FUNBUN_rec5.FUNCTION_REF
     , SDD_FUNBUN_rec5.BUSINESS_UNIT_REF
     , SDD_FUNBUN_rec5.AVERAGE_VOLUME
     , SDD_FUNBUN_rec5.FREQUENCY_UNIT
     , SDD_FUNBUN_rec5.RESPONSE_REQUIRED
     , SDD_FUNBUN_rec5.SINGLE_BUN_FLAG
     , SDD_FUNBUN_rec5.CREATED_BY_BPR
     , SDD_FUNBUN_rec5.USRX0
     , SDD_FUNBUN_rec5.USRX1
     , SDD_FUNBUN_rec5.USRX2
     , SDD_FUNBUN_rec5.USRX3
     , SDD_FUNBUN_rec5.USRX4
     , SDD_FUNBUN_rec5.USRX5
     , SDD_FUNBUN_rec5.USRX6
     , SDD_FUNBUN_rec5.USRX7
     , SDD_FUNBUN_rec5.USRX8
     , SDD_FUNBUN_rec5.USRX9
     , SDD_FUNBUN_rec5.USRX10
     , SDD_FUNBUN_rec5.USRX11
     , SDD_FUNBUN_rec5.USRX12
     , SDD_FUNBUN_rec5.USRX13
     , SDD_FUNBUN_rec5.USRX14
     , SDD_FUNBUN_rec5.USRX15
     , SDD_FUNBUN_rec5.USRX16
     , SDD_FUNBUN_rec5.USRX17
     , SDD_FUNBUN_rec5.USRX18
     , SDD_FUNBUN_rec5.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_FUNBUN_rec5.irid, SDD_FUNBUN_rec5.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_FUNENT_rec6 in SDD_FUNENT_cur6 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_FUNENT
    values (
       SDD_FUNENT_rec6.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_FUNENT_rec6.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_FUNENT_rec6.TYPES
     , SDD_FUNENT_rec6.ELEMENT_TYPE_NAME
     , SDD_FUNENT_rec6.DATE_CREATED
     , SDD_FUNENT_rec6.CREATED_BY
     , SDD_FUNENT_rec6.DATE_CHANGED
     , SDD_FUNENT_rec6.CHANGED_BY
     , SDD_FUNENT_rec6.NOTM
     , SDD_FUNENT_rec6.FUNCTION_REF
     , SDD_FUNENT_rec6.ENTITY_REF
     , SDD_FUNENT_rec6.CREATE_FLAG
     , SDD_FUNENT_rec6.RETRIEVE_FLAG
     , SDD_FUNENT_rec6.UPDATE_FLAG
     , SDD_FUNENT_rec6.DELETE_FLAG
     , SDD_FUNENT_rec6.ARCHIVE_FLAG
     , SDD_FUNENT_rec6.USER_DEFINED_USAGE_FLAG
     , SDD_FUNENT_rec6.REMARK
     , SDD_FUNENT_rec6.USRX0
     , SDD_FUNENT_rec6.USRX1
     , SDD_FUNENT_rec6.USRX2
     , SDD_FUNENT_rec6.USRX3
     , SDD_FUNENT_rec6.USRX4
     , SDD_FUNENT_rec6.USRX5
     , SDD_FUNENT_rec6.USRX6
     , SDD_FUNENT_rec6.USRX7
     , SDD_FUNENT_rec6.USRX8
     , SDD_FUNENT_rec6.USRX9
     , SDD_FUNENT_rec6.USRX10
     , SDD_FUNENT_rec6.USRX11
     , SDD_FUNENT_rec6.USRX12
     , SDD_FUNENT_rec6.USRX13
     , SDD_FUNENT_rec6.USRX14
     , SDD_FUNENT_rec6.USRX15
     , SDD_FUNENT_rec6.USRX16
     , SDD_FUNENT_rec6.USRX17
     , SDD_FUNENT_rec6.USRX18
     , SDD_FUNENT_rec6.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_FUNENT_rec6.irid, SDD_FUNENT_rec6.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_FUNEVT_rec7 in SDD_FUNEVT_cur7 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_FUNEVT
    values (
       SDD_FUNEVT_rec7.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_FUNEVT_rec7.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_FUNEVT_rec7.TYPES
     , SDD_FUNEVT_rec7.ELEMENT_TYPE_NAME
     , SDD_FUNEVT_rec7.DATE_CREATED
     , SDD_FUNEVT_rec7.CREATED_BY
     , SDD_FUNEVT_rec7.DATE_CHANGED
     , SDD_FUNEVT_rec7.CHANGED_BY
     , SDD_FUNEVT_rec7.NOTM
     , SDD_FUNEVT_rec7.TRIGGERING_FUNCTION_REF
     , SDD_FUNEVT_rec7.TRIGGERING_EVENT_REF
     , SDD_FUNEVT_rec7.TRIGGERED_FUNCTION_REF
     , SDD_FUNEVT_rec7.TRIGGERED_EVENT_REF
     , SDD_FUNEVT_rec7.PRIMARY_EVENT_FLAG
     , SDD_FUNEVT_rec7.EVENT_TRIGGER_BY
     , SDD_FUNEVT_rec7.EVENT_TRIGGER_OF
     , SDD_FUNEVT_rec7.USRX0
     , SDD_FUNEVT_rec7.USRX1
     , SDD_FUNEVT_rec7.USRX2
     , SDD_FUNEVT_rec7.USRX3
     , SDD_FUNEVT_rec7.USRX4
     , SDD_FUNEVT_rec7.USRX5
     , SDD_FUNEVT_rec7.USRX6
     , SDD_FUNEVT_rec7.USRX7
     , SDD_FUNEVT_rec7.USRX8
     , SDD_FUNEVT_rec7.USRX9
     , SDD_FUNEVT_rec7.USRX10
     , SDD_FUNEVT_rec7.USRX11
     , SDD_FUNEVT_rec7.USRX12
     , SDD_FUNEVT_rec7.USRX13
     , SDD_FUNEVT_rec7.USRX14
     , SDD_FUNEVT_rec7.USRX15
     , SDD_FUNEVT_rec7.USRX16
     , SDD_FUNEVT_rec7.USRX17
     , SDD_FUNEVT_rec7.USRX18
     , SDD_FUNEVT_rec7.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_FUNEVT_rec7.irid, SDD_FUNEVT_rec7.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  jr_reg_ver.vercopy_dependent_objects(SDD_FUN_ver.ivid, new_ivid);
  return new_ivid;
end SDD_FUN_ver;
/
create or replace function PK_SDD_FUN (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_FUN the_tab_new, SDD_FUN the_tab_old
  where  the_tab_new.ivid = PK_SDD_FUN.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_FUN.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_FUN;
/
create or replace function FK_FUN_TO_FUN (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.PARENT_REF ref_value
  from   i$SDD_FUN the_tab
  where  the_tab.ivid = FK_FUN_TO_FUN.object_ivid
  and    the_tab.PARENT_REF is not null
  and    not exists (
             select null
             from   SDD_FUN foreign_tab
             where  the_tab.PARENT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5024, action);
  end loop;
  return is_ok;
end FK_FUN_TO_FUN;
/
create or replace function FK_FUN_TO_FUN2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.COMMON_FUNCTION_REF ref_value
  from   i$SDD_FUN the_tab
  where  the_tab.ivid = FK_FUN_TO_FUN2.object_ivid
  and    the_tab.COMMON_FUNCTION_REF is not null
  and    not exists (
             select null
             from   SDD_FUN foreign_tab
             where  the_tab.COMMON_FUNCTION_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5024, action);
  end loop;
  return is_ok;
end FK_FUN_TO_FUN2;
/
create or replace function PK_SDD_FUNATT (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_FUNATT the_tab_new, SDD_FUNATT the_tab_old
  where  the_tab_new.ivid = PK_SDD_FUNATT.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_FUNATT.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_FUNATT;
/
create or replace function FK_FUNATT_TO_ATT (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ATTRIBUTE_REF ref_value
  from   i$SDD_FUNATT the_tab
  where  the_tab.ivid = FK_FUNATT_TO_ATT.object_ivid
  and    the_tab.ATTRIBUTE_REF is not null
  and    not exists (
             select null
             from   SDD_ATT foreign_tab
             where  the_tab.ATTRIBUTE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5010, action);
  end loop;
  return is_ok;
end FK_FUNATT_TO_ATT;
/
create or replace function FK_FUNATT_TO_FUNENT (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.FUNENT_REF ref_value
  from   i$SDD_FUNATT the_tab
  where  the_tab.ivid = FK_FUNATT_TO_FUNENT.object_ivid
  and    the_tab.FUNENT_REF is not null
  and    not exists (
             select null
             from   SDD_FUNENT foreign_tab
             where  the_tab.FUNENT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4988, action);
  end loop;
  return is_ok;
end FK_FUNATT_TO_FUNENT;
/
create or replace function PK_SDD_FUNBUN (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_FUNBUN the_tab_new, SDD_FUNBUN the_tab_old
  where  the_tab_new.ivid = PK_SDD_FUNBUN.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_FUNBUN.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_FUNBUN;
/
create or replace function FK_FUNBUN_TO_BUN (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.BUSINESS_UNIT_REF ref_value
  from   i$SDD_FUNBUN the_tab
  where  the_tab.ivid = FK_FUNBUN_TO_BUN.object_ivid
  and    the_tab.BUSINESS_UNIT_REF is not null
  and    not exists (
             select null
             from   SDD_BUN foreign_tab
             where  the_tab.BUSINESS_UNIT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5005, action);
  end loop;
  return is_ok;
end FK_FUNBUN_TO_BUN;
/
create or replace function PK_SDD_FUNENT (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_FUNENT the_tab_new, SDD_FUNENT the_tab_old
  where  the_tab_new.ivid = PK_SDD_FUNENT.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_FUNENT.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_FUNENT;
/
create or replace function FK_FUNENT_TO_ENT (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ENTITY_REF ref_value
  from   i$SDD_FUNENT the_tab
  where  the_tab.ivid = FK_FUNENT_TO_ENT.object_ivid
  and    the_tab.ENTITY_REF is not null
  and    not exists (
             select null
             from   SDD_ENT foreign_tab
             where  the_tab.ENTITY_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5002, action);
  end loop;
  return is_ok;
end FK_FUNENT_TO_ENT;
/
create or replace function PK_SDD_FUNEVT (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_FUNEVT the_tab_new, SDD_FUNEVT the_tab_old
  where  the_tab_new.ivid = PK_SDD_FUNEVT.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_FUNEVT.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_FUNEVT;
/
create or replace function FK_FUNEVT_TO_EVT (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.TRIGGERING_EVENT_REF ref_value
  from   i$SDD_FUNEVT the_tab
  where  the_tab.ivid = FK_FUNEVT_TO_EVT.object_ivid
  and    the_tab.TRIGGERING_EVENT_REF is not null
  and    not exists (
             select null
             from   SDD_EVT foreign_tab
             where  the_tab.TRIGGERING_EVENT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5013, action);
  end loop;
  return is_ok;
end FK_FUNEVT_TO_EVT;
/
create or replace function FK_FUNEVT_TO_FUN (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.TRIGGERING_FUNCTION_REF ref_value
  from   i$SDD_FUNEVT the_tab
  where  the_tab.ivid = FK_FUNEVT_TO_FUN.object_ivid
  and    the_tab.TRIGGERING_FUNCTION_REF is not null
  and    not exists (
             select null
             from   SDD_FUN foreign_tab
             where  the_tab.TRIGGERING_FUNCTION_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5024, action);
  end loop;
  return is_ok;
end FK_FUNEVT_TO_FUN;
/
create or replace function PK_SDD_GRP (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_GRP the_tab_new, SDD_GRP the_tab_old
  where  the_tab_new.ivid = PK_SDD_GRP.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_GRP.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_GRP;
/
create or replace function PK_SDD_GRPGRP (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_GRPGRP the_tab_new, SDD_GRPGRP the_tab_old
  where  the_tab_new.ivid = PK_SDD_GRPGRP.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_GRPGRP.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_GRPGRP;
/
create or replace function FK_GRPGRP_TO_GRP (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.GRANTOR_ROLE_REF ref_value
  from   i$SDD_GRPGRP the_tab
  where  the_tab.ivid = FK_GRPGRP_TO_GRP.object_ivid
  and    the_tab.GRANTOR_ROLE_REF is not null
  and    not exists (
             select null
             from   SDD_GRP foreign_tab
             where  the_tab.GRANTOR_ROLE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5031, action);
  end loop;
  return is_ok;
end FK_GRPGRP_TO_GRP;
/
create or replace function PK_SDD_GRPMOD (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_GRPMOD the_tab_new, SDD_GRPMOD the_tab_old
  where  the_tab_new.ivid = PK_SDD_GRPMOD.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_GRPMOD.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_GRPMOD;
/
create or replace function FK_GRPMOD_TO_GEM (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.GENERAL_MODULE_REF ref_value
  from   i$SDD_GRPMOD the_tab
  where  the_tab.ivid = FK_GRPMOD_TO_GEM.object_ivid
  and    the_tab.GENERAL_MODULE_REF is not null
  and    not exists (
             select null
             from   SDD_MOD foreign_tab
             where  the_tab.GENERAL_MODULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5022, action);
  end loop;
  return is_ok;
end FK_GRPMOD_TO_GEM;
/
create or replace function PK_SDD_IGR (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_IGR the_tab_new, SDD_IGR the_tab_old
  where  the_tab_new.ivid = PK_SDD_IGR.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_IGR.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_IGR;
/
create or replace function FK_IGR_TO_IGR (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ITEM_GROUP_REF ref_value
  from   i$SDD_IGR the_tab
  where  the_tab.ivid = FK_IGR_TO_IGR.object_ivid
  and    the_tab.ITEM_GROUP_REF is not null
  and    not exists (
             select null
             from   SDD_IGR foreign_tab
             where  the_tab.ITEM_GROUP_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4931, action);
  end loop;
  return is_ok;
end FK_IGR_TO_IGR;
/
create or replace function FK_IGR_TO_MCO (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.MODULE_COMPONENT_REF ref_value
  from   i$SDD_IGR the_tab
  where  the_tab.ivid = FK_IGR_TO_MCO.object_ivid
  and    the_tab.MODULE_COMPONENT_REF is not null
  and    not exists (
             select null
             from   SDD_MUN foreign_tab
             where  the_tab.MODULE_COMPONENT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5051, action);
  end loop;
  return is_ok;
end FK_IGR_TO_MCO;
/
create or replace function FK_IGR_TO_SUB (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.SUBCOMPONENT_REF ref_value
  from   i$SDD_IGR the_tab
  where  the_tab.ivid = FK_IGR_TO_SUB.object_ivid
  and    the_tab.SUBCOMPONENT_REF is not null
  and    not exists (
             select null
             from   SDD_MUN foreign_tab
             where  the_tab.SUBCOMPONENT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5051, action);
  end loop;
  return is_ok;
end FK_IGR_TO_SUB;
/
create or replace function PK_SDD_IND (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_IND the_tab_new, SDD_IND the_tab_old
  where  the_tab_new.ivid = PK_SDD_IND.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_IND.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_IND;
/
create or replace function FK_IND_TO_FCO (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.FOREIGN_KEY_REF ref_value
  from   i$SDD_IND the_tab
  where  the_tab.ivid = FK_IND_TO_FCO.object_ivid
  and    the_tab.FOREIGN_KEY_REF is not null
  and    not exists (
             select null
             from   SDD_OCO foreign_tab
             where  the_tab.FOREIGN_KEY_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5027, action);
  end loop;
  return is_ok;
end FK_IND_TO_FCO;
/
create or replace function PK_SDD_INDCOL (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_INDCOL the_tab_new, SDD_INDCOL the_tab_old
  where  the_tab_new.ivid = PK_SDD_INDCOL.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_INDCOL.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_INDCOL;
/
create or replace function FK_INDCOL_TO_COL (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.COLUMN_REF ref_value
  from   i$SDD_INDCOL the_tab
  where  the_tab.ivid = FK_INDCOL_TO_COL.object_ivid
  and    the_tab.COLUMN_REF is not null
  and    not exists (
             select null
             from   SDD_COL foreign_tab
             where  the_tab.COLUMN_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5014, action);
  end loop;
  return is_ok;
end FK_INDCOL_TO_COL;
/
create or replace function FK_INDCOL_TO_CQA (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.CQA_REF ref_value
  from   i$SDD_INDCOL the_tab
  where  the_tab.ivid = FK_INDCOL_TO_CQA.object_ivid
  and    the_tab.CQA_REF is not null
  and    not exists (
             select null
             from   SDD_CQA foreign_tab
             where  the_tab.CQA_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4856, action);
  end loop;
  return is_ok;
end FK_INDCOL_TO_CQA;
/
create or replace function PK_SDD_INP (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_INP the_tab_new, SDD_INP the_tab_old
  where  the_tab_new.ivid = PK_SDD_INP.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_INP.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_INP;
/
create or replace function FK_INP_TO_OSP (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.STORAGE_DEFINITION_REF ref_value
  from   i$SDD_INP the_tab
  where  the_tab.ivid = FK_INP_TO_OSP.object_ivid
  and    the_tab.STORAGE_DEFINITION_REF is not null
  and    not exists (
             select null
             from   SDD_OSP foreign_tab
             where  the_tab.STORAGE_DEFINITION_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5000, action);
  end loop;
  return is_ok;
end FK_INP_TO_OSP;
/
create or replace function FK_INP_TO_OTB (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.TABLESPACE_REF ref_value
  from   i$SDD_INP the_tab
  where  the_tab.ivid = FK_INP_TO_OTB.object_ivid
  and    the_tab.TABLESPACE_REF is not null
  and    not exists (
             select null
             from   SDD_OTB foreign_tab
             where  the_tab.TABLESPACE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5001, action);
  end loop;
  return is_ok;
end FK_INP_TO_OTB;
/
create or replace function FK_INP_TO_TBP (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.TABLE_PARTITION_REF ref_value
  from   i$SDD_INP the_tab
  where  the_tab.ivid = FK_INP_TO_TBP.object_ivid
  and    the_tab.TABLE_PARTITION_REF is not null
  and    not exists (
             select null
             from   SDD_TBP foreign_tab
             where  the_tab.TABLE_PARTITION_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4887, action);
  end loop;
  return is_ok;
end FK_INP_TO_TBP;
/
create or replace function PK_SDD_INS (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_INS the_tab_new, SDD_INS the_tab_old
  where  the_tab_new.ivid = PK_SDD_INS.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_INS.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_INS;
/
create or replace function FK_INS_TO_IND (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.INDEX_REF ref_value
  from   i$SDD_INS the_tab
  where  the_tab.ivid = FK_INS_TO_IND.object_ivid
  and    the_tab.INDEX_REF is not null
  and    not exists (
             select null
             from   SDD_IND foreign_tab
             where  the_tab.INDEX_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5029, action);
  end loop;
  return is_ok;
end FK_INS_TO_IND;
/
create or replace function FK_INS_TO_OSP (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.STORAGE_DEFINITION_REF ref_value
  from   i$SDD_INS the_tab
  where  the_tab.ivid = FK_INS_TO_OSP.object_ivid
  and    the_tab.STORAGE_DEFINITION_REF is not null
  and    not exists (
             select null
             from   SDD_OSP foreign_tab
             where  the_tab.STORAGE_DEFINITION_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5000, action);
  end loop;
  return is_ok;
end FK_INS_TO_OSP;
/
create or replace function FK_INS_TO_OTB (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.TABLESPACE_REF ref_value
  from   i$SDD_INS the_tab
  where  the_tab.ivid = FK_INS_TO_OTB.object_ivid
  and    the_tab.TABLESPACE_REF is not null
  and    not exists (
             select null
             from   SDD_OTB foreign_tab
             where  the_tab.TABLESPACE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5001, action);
  end loop;
  return is_ok;
end FK_INS_TO_OTB;
/
create or replace function FK_INS_TO_PCO (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.PRIMARY_KEY_REF ref_value
  from   i$SDD_INS the_tab
  where  the_tab.ivid = FK_INS_TO_PCO.object_ivid
  and    the_tab.PRIMARY_KEY_REF is not null
  and    not exists (
             select null
             from   SDD_OCO foreign_tab
             where  the_tab.PRIMARY_KEY_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5027, action);
  end loop;
  return is_ok;
end FK_INS_TO_PCO;
/
create or replace function FK_INS_TO_UCO (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.UNIQUE_KEY_REF ref_value
  from   i$SDD_INS the_tab
  where  the_tab.ivid = FK_INS_TO_UCO.object_ivid
  and    the_tab.UNIQUE_KEY_REF is not null
  and    not exists (
             select null
             from   SDD_OCO foreign_tab
             where  the_tab.UNIQUE_KEY_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5027, action);
  end loop;
  return is_ok;
end FK_INS_TO_UCO;
/
create or replace function PK_SDD_ITE (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_ITE the_tab_new, SDD_ITE the_tab_old
  where  the_tab_new.ivid = PK_SDD_ITE.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_ITE.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_ITE;
/
create or replace function FK_ITE_TO_COL (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.COLUMN_REF ref_value
  from   i$SDD_ITE the_tab
  where  the_tab.ivid = FK_ITE_TO_COL.object_ivid
  and    the_tab.COLUMN_REF is not null
  and    not exists (
             select null
             from   SDD_COL foreign_tab
             where  the_tab.COLUMN_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5014, action);
  end loop;
  return is_ok;
end FK_ITE_TO_COL;
/
create or replace function FK_ITE_TO_DOM (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.DOMAIN_REF ref_value
  from   i$SDD_ITE the_tab
  where  the_tab.ivid = FK_ITE_TO_DOM.object_ivid
  and    the_tab.DOMAIN_REF is not null
  and    not exists (
             select null
             from   SDD_DOM foreign_tab
             where  the_tab.DOMAIN_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5020, action);
  end loop;
  return is_ok;
end FK_ITE_TO_DOM;
/
create or replace function FK_ITE_TO_IGR (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ITEM_GROUP_REF ref_value
  from   i$SDD_ITE the_tab
  where  the_tab.ivid = FK_ITE_TO_IGR.object_ivid
  and    the_tab.ITEM_GROUP_REF is not null
  and    not exists (
             select null
             from   SDD_IGR foreign_tab
             where  the_tab.ITEM_GROUP_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4931, action);
  end loop;
  return is_ok;
end FK_ITE_TO_IGR;
/
create or replace function FK_ITE_TO_MTI (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.DETAIL_TABLE_USAGE_REF ref_value
  from   i$SDD_ITE the_tab
  where  the_tab.ivid = FK_ITE_TO_MTI.object_ivid
  and    the_tab.DETAIL_TABLE_USAGE_REF is not null
  and    not exists (
             select null
             from   SDD_MTI foreign_tab
             where  the_tab.DETAIL_TABLE_USAGE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4998, action);
  end loop;
  return is_ok;
end FK_ITE_TO_MTI;
/
create or replace function FK_ITE_TO_MUN (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.MODULE_UNIT_REF ref_value
  from   i$SDD_ITE the_tab
  where  the_tab.ivid = FK_ITE_TO_MUN.object_ivid
  and    the_tab.MODULE_UNIT_REF is not null
  and    not exists (
             select null
             from   SDD_MUN foreign_tab
             where  the_tab.MODULE_UNIT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5051, action);
  end loop;
  return is_ok;
end FK_ITE_TO_MUN;
/
create or replace function PK_SDD_ITM (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_ITM the_tab_new, SDD_ITM the_tab_old
  where  the_tab_new.ivid = PK_SDD_ITM.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_ITM.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_ITM;
/
create or replace function FK_ITM_TO_COL (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.COLUMN_REF ref_value
  from   i$SDD_ITM the_tab
  where  the_tab.ivid = FK_ITM_TO_COL.object_ivid
  and    the_tab.COLUMN_REF is not null
  and    not exists (
             select null
             from   SDD_COL foreign_tab
             where  the_tab.COLUMN_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5014, action);
  end loop;
  return is_ok;
end FK_ITM_TO_COL;
/
create or replace function FK_ITM_TO_CQA (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.CQA_REF ref_value
  from   i$SDD_ITM the_tab
  where  the_tab.ivid = FK_ITM_TO_CQA.object_ivid
  and    the_tab.CQA_REF is not null
  and    not exists (
             select null
             from   SDD_CQA foreign_tab
             where  the_tab.CQA_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4856, action);
  end loop;
  return is_ok;
end FK_ITM_TO_CQA;
/
create or replace function FK_ITM_TO_DAT2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.DATASTRUCTURE_REF2 ref_value
  from   i$SDD_ITM the_tab
  where  the_tab.ivid = FK_ITM_TO_DAT2.object_ivid
  and    the_tab.DATASTRUCTURE_REF2 is not null
  and    not exists (
             select null
             from   SDD_DAT foreign_tab
             where  the_tab.DATASTRUCTURE_REF2 = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5045, action);
  end loop;
  return is_ok;
end FK_ITM_TO_DAT2;
/
create or replace function FK_ITM_TO_DOM (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.DOMAIN_REF ref_value
  from   i$SDD_ITM the_tab
  where  the_tab.ivid = FK_ITM_TO_DOM.object_ivid
  and    the_tab.DOMAIN_REF is not null
  and    not exists (
             select null
             from   SDD_DOM foreign_tab
             where  the_tab.DOMAIN_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5020, action);
  end loop;
  return is_ok;
end FK_ITM_TO_DOM;
/
create or replace function FK_ITM_TO_ORT (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ORACLE_TYPE_REF ref_value
  from   i$SDD_ITM the_tab
  where  the_tab.ivid = FK_ITM_TO_ORT.object_ivid
  and    the_tab.ORACLE_TYPE_REF is not null
  and    not exists (
             select null
             from   SDD_ORT foreign_tab
             where  the_tab.ORACLE_TYPE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4858, action);
  end loop;
  return is_ok;
end FK_ITM_TO_ORT;
/
create or replace function FK_ITM_TO_PGD (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.PROGRAM_DATUM_REF ref_value
  from   i$SDD_ITM the_tab
  where  the_tab.ivid = FK_ITM_TO_PGD.object_ivid
  and    the_tab.PROGRAM_DATUM_REF is not null
  and    not exists (
             select null
             from   SDD_PGD foreign_tab
             where  the_tab.PROGRAM_DATUM_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4984, action);
  end loop;
  return is_ok;
end FK_ITM_TO_PGD;
/
create or replace function FK_ITM_TO_PLM (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.PLSQL_MODULE_REF ref_value
  from   i$SDD_ITM the_tab
  where  the_tab.ivid = FK_ITM_TO_PLM.object_ivid
  and    the_tab.PLSQL_MODULE_REF is not null
  and    not exists (
             select null
             from   SDD_MOD foreign_tab
             where  the_tab.PLSQL_MODULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5022, action);
  end loop;
  return is_ok;
end FK_ITM_TO_PLM;
/
create or replace function FK_ITM_TO_PLM2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.CURSOR_REF ref_value
  from   i$SDD_ITM the_tab
  where  the_tab.ivid = FK_ITM_TO_PLM2.object_ivid
  and    the_tab.CURSOR_REF is not null
  and    not exists (
             select null
             from   SDD_MOD foreign_tab
             where  the_tab.CURSOR_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5022, action);
  end loop;
  return is_ok;
end FK_ITM_TO_PLM2;
/
create or replace function FK_ITM_TO_TBL (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.TABLE_DEFINITION_REF ref_value
  from   i$SDD_ITM the_tab
  where  the_tab.ivid = FK_ITM_TO_TBL.object_ivid
  and    the_tab.TABLE_DEFINITION_REF is not null
  and    not exists (
             select null
             from   SDD_TAB foreign_tab
             where  the_tab.TABLE_DEFINITION_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4982, action);
  end loop;
  return is_ok;
end FK_ITM_TO_TBL;
/
create or replace function FK_MOD_TO_LAN_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_MOD child_tab
  where  child_tab.LANGUAGE_REF=FK_MOD_TO_LAN_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_MOD child_tab, i$sdd_object_versions o
    where  child_tab.LANGUAGE_REF=FK_MOD_TO_LAN_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_MOD_TO_LAN_d;
/
create or replace function FK_MUN_TO_LAN_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_MUN child_tab
  where  child_tab.LANGUAGE_REF=FK_MUN_TO_LAN_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_MUN child_tab, i$sdd_object_versions o
    where  child_tab.LANGUAGE_REF=FK_MUN_TO_LAN_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_MUN_TO_LAN_d;
/
create or replace function SDD_LAN_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_LAN_cur is
    select *
    from   i$SDD_LAN the_tab
    where  the_tab.irid=SDD_LAN_ver.irid
    and    the_tab.ivid=SDD_LAN_ver.ivid;
  SDD_LAN_rec SDD_LAN_cur%ROWTYPE;
  cursor SDD_MWF_cur1 is
    select *
    from i$SDD_MWF the_tab
    where the_tab.parent_ivid=SDD_LAN_ver.ivid;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_LAN_cur;
  fetch SDD_LAN_cur into SDD_LAN_rec;
  close SDD_LAN_cur;
  insert into i$SDD_LAN
  values (
    SDD_LAN_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_LAN_rec.TYPES
   ,SDD_LAN_rec.ELEMENT_TYPE_NAME
   ,SDD_LAN_rec.DATE_CREATED
   ,SDD_LAN_rec.CREATED_BY
   ,SDD_LAN_rec.DATE_CHANGED
   ,SDD_LAN_rec.CHANGED_BY
   ,SDD_LAN_rec.NOTM
   ,SDD_LAN_rec.NAME
   ,SDD_LAN_rec.LANGUAGE_TYPE
   ,SDD_LAN_rec.SOURCE_DIRECTORY
   ,SDD_LAN_rec.RUNTIME_DIRECTORY
   ,SDD_LAN_rec.COMMAND_LINE
   ,SDD_LAN_rec.DESCRIPTION
   ,SDD_LAN_rec.GENERATABLE_FLAG
   ,SDD_LAN_rec.INTERNAL_NAME
   ,SDD_LAN_rec.OBM_FLAG
   ,SDD_LAN_rec.USRX0
   ,SDD_LAN_rec.USRX1
   ,SDD_LAN_rec.USRX2
   ,SDD_LAN_rec.USRX3
   ,SDD_LAN_rec.USRX4
   ,SDD_LAN_rec.USRX5
   ,SDD_LAN_rec.USRX6
   ,SDD_LAN_rec.USRX7
   ,SDD_LAN_rec.USRX8
   ,SDD_LAN_rec.USRX9
   ,SDD_LAN_rec.USRX10
   ,SDD_LAN_rec.USRX11
   ,SDD_LAN_rec.USRX12
   ,SDD_LAN_rec.USRX13
   ,SDD_LAN_rec.USRX14
   ,SDD_LAN_rec.USRX15
   ,SDD_LAN_rec.USRX16
   ,SDD_LAN_rec.USRX17
   ,SDD_LAN_rec.USRX18
   ,SDD_LAN_rec.USRX19
  );
  jr_reg_ver.vercopy_dependencies(SDD_LAN_ver.irid, SDD_LAN_ver.ivid, new_ivid, null, copy_dependencies);
  for SDD_MWF_rec1 in SDD_MWF_cur1 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_MWF
    values (
       SDD_MWF_rec1.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_MWF_rec1.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_MWF_rec1.TYPES
     , SDD_MWF_rec1.ELEMENT_TYPE_NAME
     , SDD_MWF_rec1.DATE_CREATED
     , SDD_MWF_rec1.CREATED_BY
     , SDD_MWF_rec1.DATE_CHANGED
     , SDD_MWF_rec1.CHANGED_BY
     , SDD_MWF_rec1.NOTM
     , SDD_MWF_rec1.LANGUAGE_REF
     , SDD_MWF_rec1.COMPLEXITY
     , SDD_MWF_rec1.MODULE_TYPE
     , SDD_MWF_rec1.ESTIMATE
     , SDD_MWF_rec1.ESTIMATE_UNITS
     , SDD_MWF_rec1.USRX0
     , SDD_MWF_rec1.USRX1
     , SDD_MWF_rec1.USRX2
     , SDD_MWF_rec1.USRX3
     , SDD_MWF_rec1.USRX4
     , SDD_MWF_rec1.USRX5
     , SDD_MWF_rec1.USRX6
     , SDD_MWF_rec1.USRX7
     , SDD_MWF_rec1.USRX8
     , SDD_MWF_rec1.USRX9
     , SDD_MWF_rec1.USRX10
     , SDD_MWF_rec1.USRX11
     , SDD_MWF_rec1.USRX12
     , SDD_MWF_rec1.USRX13
     , SDD_MWF_rec1.USRX14
     , SDD_MWF_rec1.USRX15
     , SDD_MWF_rec1.USRX16
     , SDD_MWF_rec1.USRX17
     , SDD_MWF_rec1.USRX18
     , SDD_MWF_rec1.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_MWF_rec1.irid, SDD_MWF_rec1.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  jr_reg_ver.vercopy_dependent_objects(SDD_LAN_ver.ivid, new_ivid);
  return new_ivid;
end SDD_LAN_ver;
/
create or replace function PK_SDD_LAN (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_LAN the_tab_new, SDD_LAN the_tab_old
  where  the_tab_new.ivid = PK_SDD_LAN.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_LAN.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_LAN;
/
create or replace function FK_CST_TO_LST_cmd (irid number, ivid number) return boolean as
cursor bad_cur is
  select child_tab.irid child_irid, child_tab.types child_type
        ,parent_tab.ivid par_ivid, parent_tab.types par_type
  from   SDD_CST child_tab, i$SDD_LST parent_tab
  where  parent_tab.parent_ivid=FK_CST_TO_LST_cmd.ivid
  and    child_tab.LOB_STORAGE_REF=parent_tab.IRID
  ;
  is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
   insert into I$SDD_INVALID_OBJECTS(object_irid,object_ivid,table_irid)
    select o.irid,o.ivid,o.table_irid
      from SDD_CST child_tab
          ,i$SDD_LST parent_tab
          ,I$SDD_OBJECT_VERSIONS o
     where parent_tab.parent_ivid=FK_CST_TO_LST_cmd.ivid
       and child_tab.LOB_STORAGE_REF=parent_tab.IRID
       and child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(ref.par_ivid,ref.par_type,ref.child_irid,ref.child_type,'DEL');
  end loop;
  return is_ok;
end FK_CST_TO_LST_cmd;
/
create or replace function FK_CST_TO_LST_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_CST child_tab
  where  child_tab.LOB_STORAGE_REF=FK_CST_TO_LST_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_CST child_tab, i$sdd_object_versions o
    where  child_tab.LOB_STORAGE_REF=FK_CST_TO_LST_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_CST_TO_LST_d;
/
create or replace function PK_SDD_LST (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_LST the_tab_new, SDD_LST the_tab_old
  where  the_tab_new.ivid = PK_SDD_LST.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_LST.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_LST;
/
create or replace function FK_LST_TO_OSP (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.STORAGE_DEFINITION_REF ref_value
  from   i$SDD_LST the_tab
  where  the_tab.ivid = FK_LST_TO_OSP.object_ivid
  and    the_tab.STORAGE_DEFINITION_REF is not null
  and    not exists (
             select null
             from   SDD_OSP foreign_tab
             where  the_tab.STORAGE_DEFINITION_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5000, action);
  end loop;
  return is_ok;
end FK_LST_TO_OSP;
/
create or replace function FK_LST_TO_OSP2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.INDEX_STORAGE_DEFN_REF ref_value
  from   i$SDD_LST the_tab
  where  the_tab.ivid = FK_LST_TO_OSP2.object_ivid
  and    the_tab.INDEX_STORAGE_DEFN_REF is not null
  and    not exists (
             select null
             from   SDD_OSP foreign_tab
             where  the_tab.INDEX_STORAGE_DEFN_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5000, action);
  end loop;
  return is_ok;
end FK_LST_TO_OSP2;
/
create or replace function FK_LST_TO_OTB (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.TABLESPACE_REF ref_value
  from   i$SDD_LST the_tab
  where  the_tab.ivid = FK_LST_TO_OTB.object_ivid
  and    the_tab.TABLESPACE_REF is not null
  and    not exists (
             select null
             from   SDD_OTB foreign_tab
             where  the_tab.TABLESPACE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5001, action);
  end loop;
  return is_ok;
end FK_LST_TO_OTB;
/
create or replace function FK_LST_TO_OTB2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.INDEX_TABLESPACE_REF ref_value
  from   i$SDD_LST the_tab
  where  the_tab.ivid = FK_LST_TO_OTB2.object_ivid
  and    the_tab.INDEX_TABLESPACE_REF is not null
  and    not exists (
             select null
             from   SDD_OTB foreign_tab
             where  the_tab.INDEX_TABLESPACE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5001, action);
  end loop;
  return is_ok;
end FK_LST_TO_OTB2;
/
create or replace function PK_SDD_LVI (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_LVI the_tab_new, SDD_LVI the_tab_old
  where  the_tab_new.ivid = PK_SDD_LVI.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_LVI.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_LVI;
/
create or replace function FK_LVI_TO_GEM (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.GENERAL_MODULE_REF ref_value
  from   i$SDD_LVI the_tab
  where  the_tab.ivid = FK_LVI_TO_GEM.object_ivid
  and    the_tab.GENERAL_MODULE_REF is not null
  and    not exists (
             select null
             from   SDD_MOD foreign_tab
             where  the_tab.GENERAL_MODULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5022, action);
  end loop;
  return is_ok;
end FK_LVI_TO_GEM;
/
create or replace function FK_LVI_TO_ITE (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ITEM_REF ref_value
  from   i$SDD_LVI the_tab
  where  the_tab.ivid = FK_LVI_TO_ITE.object_ivid
  and    the_tab.ITEM_REF is not null
  and    not exists (
             select null
             from   SDD_ITE foreign_tab
             where  the_tab.ITEM_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4997, action);
  end loop;
  return is_ok;
end FK_LVI_TO_ITE;
/
create or replace function FK_LVI_TO_LOV (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.LIST_OF_VALUES_REF ref_value
  from   i$SDD_LVI the_tab
  where  the_tab.ivid = FK_LVI_TO_LOV.object_ivid
  and    the_tab.LIST_OF_VALUES_REF is not null
  and    not exists (
             select null
             from   SDD_MUN foreign_tab
             where  the_tab.LIST_OF_VALUES_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5051, action);
  end loop;
  return is_ok;
end FK_LVI_TO_LOV;
/
create or replace function PK_SDD_MAP (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_MAP the_tab_new, SDD_MAP the_tab_old
  where  the_tab_new.ivid = PK_SDD_MAP.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_MAP.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_MAP;
/
create or replace function FK_MAP_TO_MAP (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.PRIMARY_MAPPING_REF ref_value
  from   i$SDD_MAP the_tab
  where  the_tab.ivid = FK_MAP_TO_MAP.object_ivid
  and    the_tab.PRIMARY_MAPPING_REF is not null
  and    not exists (
             select null
             from   SDD_MAP foreign_tab
             where  the_tab.PRIMARY_MAPPING_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4847, action);
  end loop;
  return is_ok;
end FK_MAP_TO_MAP;
/
create or replace function PK_SDD_MCH (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_MCH the_tab_new, SDD_MCH the_tab_old
  where  the_tab_new.ivid = PK_SDD_MCH.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_MCH.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_MCH;
/
create or replace function FK_MCH_TO_MOD (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.MODULE_REF ref_value
  from   i$SDD_MCH the_tab
  where  the_tab.ivid = FK_MCH_TO_MOD.object_ivid
  and    the_tab.MODULE_REF is not null
  and    not exists (
             select null
             from   SDD_MOD foreign_tab
             where  the_tab.MODULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5022, action);
  end loop;
  return is_ok;
end FK_MCH_TO_MOD;
/
create or replace function PK_SDD_MCL (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_MCL the_tab_new, SDD_MCL the_tab_old
  where  the_tab_new.ivid = PK_SDD_MCL.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_MCL.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_MCL;
/
create or replace function UK_MCL (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_MCL the_tab_new, SDD_MCL the_tab_old
  where  the_tab_new.ivid = UK_MCL.ivid
  and    the_tab_new.MCN_REF_FROM = the_tab_old.MCN_REF_FROM
  and    the_tab_new.MCN_REF_TO = the_tab_old.MCN_REF_TO
  and    the_tab_old.ivid != UK_MCL.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end UK_MCL;
/
create or replace function FK_MCL_TO_GEM (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.MODULE_REF_FROM ref_value
  from   i$SDD_MCL the_tab
  where  the_tab.ivid = FK_MCL_TO_GEM.object_ivid
  and    the_tab.MODULE_REF_FROM is not null
  and    not exists (
             select null
             from   SDD_MOD foreign_tab
             where  the_tab.MODULE_REF_FROM = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5022, action);
  end loop;
  return is_ok;
end FK_MCL_TO_GEM;
/
create or replace function FK_MCL_TO_GEM2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.MODULE_REF_TO ref_value
  from   i$SDD_MCL the_tab
  where  the_tab.ivid = FK_MCL_TO_GEM2.object_ivid
  and    the_tab.MODULE_REF_TO is not null
  and    not exists (
             select null
             from   SDD_MOD foreign_tab
             where  the_tab.MODULE_REF_TO = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5022, action);
  end loop;
  return is_ok;
end FK_MCL_TO_GEM2;
/
create or replace function FK_MCL_TO_JCO (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.JOIN_CONSTRAINT_REF ref_value
  from   i$SDD_MCL the_tab
  where  the_tab.ivid = FK_MCL_TO_JCO.object_ivid
  and    the_tab.JOIN_CONSTRAINT_REF is not null
  and    not exists (
             select null
             from   SDD_OCO foreign_tab
             where  the_tab.JOIN_CONSTRAINT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5027, action);
  end loop;
  return is_ok;
end FK_MCL_TO_JCO;
/
create or replace function FK_MCL_TO_MCN (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.MCN_REF_FROM ref_value
  from   i$SDD_MCL the_tab
  where  the_tab.ivid = FK_MCL_TO_MCN.object_ivid
  and    the_tab.MCN_REF_FROM is not null
  and    not exists (
             select null
             from   SDD_MCN foreign_tab
             where  the_tab.MCN_REF_FROM = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4918, action);
  end loop;
  return is_ok;
end FK_MCL_TO_MCN;
/
create or replace function FK_MCL_TO_MCN2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.MCN_REF_TO ref_value
  from   i$SDD_MCL the_tab
  where  the_tab.ivid = FK_MCL_TO_MCN2.object_ivid
  and    the_tab.MCN_REF_TO is not null
  and    not exists (
             select null
             from   SDD_MCN foreign_tab
             where  the_tab.MCN_REF_TO = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4918, action);
  end loop;
  return is_ok;
end FK_MCL_TO_MCN2;
/
create or replace function FK_MCL_TO_MTI (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.TABLE_USAGE_REF_FROM ref_value
  from   i$SDD_MCL the_tab
  where  the_tab.ivid = FK_MCL_TO_MTI.object_ivid
  and    the_tab.TABLE_USAGE_REF_FROM is not null
  and    not exists (
             select null
             from   SDD_MTI foreign_tab
             where  the_tab.TABLE_USAGE_REF_FROM = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4998, action);
  end loop;
  return is_ok;
end FK_MCL_TO_MTI;
/
create or replace function FK_MCL_TO_MTI2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.TABLE_USAGE_REF_TO ref_value
  from   i$SDD_MCL the_tab
  where  the_tab.ivid = FK_MCL_TO_MTI2.object_ivid
  and    the_tab.TABLE_USAGE_REF_TO is not null
  and    not exists (
             select null
             from   SDD_MTI foreign_tab
             where  the_tab.TABLE_USAGE_REF_TO = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4998, action);
  end loop;
  return is_ok;
end FK_MCL_TO_MTI2;
/
create or replace function FK_MCL_TO_PCO (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.PRIMARY_KEY_REF ref_value
  from   i$SDD_MCL the_tab
  where  the_tab.ivid = FK_MCL_TO_PCO.object_ivid
  and    the_tab.PRIMARY_KEY_REF is not null
  and    not exists (
             select null
             from   SDD_OCO foreign_tab
             where  the_tab.PRIMARY_KEY_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5027, action);
  end loop;
  return is_ok;
end FK_MCL_TO_PCO;
/
create or replace function PK_SDD_MCN (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_MCN the_tab_new, SDD_MCN the_tab_old
  where  the_tab_new.ivid = PK_SDD_MCN.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_MCN.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_MCN;
/
create or replace function FK_MCN_TO_GEM (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.GENERAL_MODULE_REF ref_value
  from   i$SDD_MCN the_tab
  where  the_tab.ivid = FK_MCN_TO_GEM.object_ivid
  and    the_tab.GENERAL_MODULE_REF is not null
  and    not exists (
             select null
             from   SDD_MOD foreign_tab
             where  the_tab.GENERAL_MODULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5022, action);
  end loop;
  return is_ok;
end FK_MCN_TO_GEM;
/
create or replace function FK_MCN_TO_MCN (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.PARENT_MCN_REF ref_value
  from   i$SDD_MCN the_tab
  where  the_tab.ivid = FK_MCN_TO_MCN.object_ivid
  and    the_tab.PARENT_MCN_REF is not null
  and    not exists (
             select null
             from   SDD_MCN foreign_tab
             where  the_tab.PARENT_MCN_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4918, action);
  end loop;
  return is_ok;
end FK_MCN_TO_MCN;
/
create or replace function FK_MCN_TO_MCN2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.RIGHT_OF_MCN_REF ref_value
  from   i$SDD_MCN the_tab
  where  the_tab.ivid = FK_MCN_TO_MCN2.object_ivid
  and    the_tab.RIGHT_OF_MCN_REF is not null
  and    not exists (
             select null
             from   SDD_MCN foreign_tab
             where  the_tab.RIGHT_OF_MCN_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4918, action);
  end loop;
  return is_ok;
end FK_MCN_TO_MCN2;
/
create or replace function FK_MCN_TO_MCO (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.MODULE_COMPONENT_REF ref_value
  from   i$SDD_MCN the_tab
  where  the_tab.ivid = FK_MCN_TO_MCO.object_ivid
  and    the_tab.MODULE_COMPONENT_REF is not null
  and    not exists (
             select null
             from   SDD_MUN foreign_tab
             where  the_tab.MODULE_COMPONENT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5051, action);
  end loop;
  return is_ok;
end FK_MCN_TO_MCO;
/
create or replace function FK_MCN_TO_SUB (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.SUBCOMPONENT_REF ref_value
  from   i$SDD_MCN the_tab
  where  the_tab.ivid = FK_MCN_TO_SUB.object_ivid
  and    the_tab.SUBCOMPONENT_REF is not null
  and    not exists (
             select null
             from   SDD_MUN foreign_tab
             where  the_tab.SUBCOMPONENT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5051, action);
  end loop;
  return is_ok;
end FK_MCN_TO_SUB;
/
create or replace function FK_MCN_TO_WIN (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.WINDOW_REF ref_value
  from   i$SDD_MCN the_tab
  where  the_tab.ivid = FK_MCN_TO_WIN.object_ivid
  and    the_tab.WINDOW_REF is not null
  and    not exists (
             select null
             from   SDD_WIN foreign_tab
             where  the_tab.WINDOW_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4919, action);
  end loop;
  return is_ok;
end FK_MCN_TO_WIN;
/
create or replace function PK_SDD_MEMCOM (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_MEMCOM the_tab_new, SDD_MEMCOM the_tab_old
  where  the_tab_new.ivid = PK_SDD_MEMCOM.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_MEMCOM.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_MEMCOM;
/
create or replace function FK_MEMCOM_TO_AEN (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ASSOCIATION_END_REF ref_value
  from   i$SDD_MEMCOM the_tab
  where  the_tab.ivid = FK_MEMCOM_TO_AEN.object_ivid
  and    the_tab.ASSOCIATION_END_REF is not null
  and    not exists (
             select null
             from   SDD_AEN foreign_tab
             where  the_tab.ASSOCIATION_END_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5065, action);
  end loop;
  return is_ok;
end FK_MEMCOM_TO_AEN;
/
create or replace function FK_MEMCOM_TO_CAT (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.CLASSIFIER_ATTRIBUTE_REF ref_value
  from   i$SDD_MEMCOM the_tab
  where  the_tab.ivid = FK_MEMCOM_TO_CAT.object_ivid
  and    the_tab.CLASSIFIER_ATTRIBUTE_REF is not null
  and    not exists (
             select null
             from   SDD_CAT foreign_tab
             where  the_tab.CLASSIFIER_ATTRIBUTE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5066, action);
  end loop;
  return is_ok;
end FK_MEMCOM_TO_CAT;
/
create or replace function FK_MEMCOM_TO_MET (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.METHOD_REF ref_value
  from   i$SDD_MEMCOM the_tab
  where  the_tab.ivid = FK_MEMCOM_TO_MET.object_ivid
  and    the_tab.METHOD_REF is not null
  and    not exists (
             select null
             from   SDD_MET foreign_tab
             where  the_tab.METHOD_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4834, action);
  end loop;
  return is_ok;
end FK_MEMCOM_TO_MET;
/
create or replace function PK_SDD_MET (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_MET the_tab_new, SDD_MET the_tab_old
  where  the_tab_new.ivid = PK_SDD_MET.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_MET.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_MET;
/
create or replace function FK_MET_TO_CLA2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.RETURN_CLASSIFIER_REF ref_value
  from   i$SDD_MET the_tab
  where  the_tab.ivid = FK_MET_TO_CLA2.object_ivid
  and    the_tab.RETURN_CLASSIFIER_REF is not null
  and    not exists (
             select null
             from   SDD_CLA foreign_tab
             where  the_tab.RETURN_CLASSIFIER_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4841, action);
  end loop;
  return is_ok;
end FK_MET_TO_CLA2;
/
create or replace function FK_MET_TO_CLA3 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.COLLECT_CLASSIFIER_REF ref_value
  from   i$SDD_MET the_tab
  where  the_tab.ivid = FK_MET_TO_CLA3.object_ivid
  and    the_tab.COLLECT_CLASSIFIER_REF is not null
  and    not exists (
             select null
             from   SDD_CLA foreign_tab
             where  the_tab.COLLECT_CLASSIFIER_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4841, action);
  end loop;
  return is_ok;
end FK_MET_TO_CLA3;
/
create or replace function FK_MET_TO_MET (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ELEVATED_METHOD_REF ref_value
  from   i$SDD_MET the_tab
  where  the_tab.ivid = FK_MET_TO_MET.object_ivid
  and    the_tab.ELEVATED_METHOD_REF is not null
  and    not exists (
             select null
             from   SDD_MET foreign_tab
             where  the_tab.ELEVATED_METHOD_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4834, action);
  end loop;
  return is_ok;
end FK_MET_TO_MET;
/
create or replace function FK_MET_TO_MET2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.OVERRIDING_METHOD_REF ref_value
  from   i$SDD_MET the_tab
  where  the_tab.ivid = FK_MET_TO_MET2.object_ivid
  and    the_tab.OVERRIDING_METHOD_REF is not null
  and    not exists (
             select null
             from   SDD_MET foreign_tab
             where  the_tab.OVERRIDING_METHOD_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4834, action);
  end loop;
  return is_ok;
end FK_MET_TO_MET2;
/
create or replace function PK_SDD_METRUL (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_METRUL the_tab_new, SDD_METRUL the_tab_old
  where  the_tab_new.ivid = PK_SDD_METRUL.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_METRUL.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_METRUL;
/
create or replace function FK_METRUL_TO_ADR (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ATTRIBUTE_DERIV_RULE_REF ref_value
  from   i$SDD_METRUL the_tab
  where  the_tab.ivid = FK_METRUL_TO_ADR.object_ivid
  and    the_tab.ATTRIBUTE_DERIV_RULE_REF is not null
  and    not exists (
             select null
             from   SDD_ADR foreign_tab
             where  the_tab.ATTRIBUTE_DERIV_RULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5090, action);
  end loop;
  return is_ok;
end FK_METRUL_TO_ADR;
/
create or replace function FK_METRUL_TO_COR (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.CROSS_OBJECT_RULE_REF ref_value
  from   i$SDD_METRUL the_tab
  where  the_tab.ivid = FK_METRUL_TO_COR.object_ivid
  and    the_tab.CROSS_OBJECT_RULE_REF is not null
  and    not exists (
             select null
             from   SDD_COR foreign_tab
             where  the_tab.CROSS_OBJECT_RULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5091, action);
  end loop;
  return is_ok;
end FK_METRUL_TO_COR;
/
create or replace function FK_METRUL_TO_CRU (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.CLASSIFIER_RULE_REF ref_value
  from   i$SDD_METRUL the_tab
  where  the_tab.ivid = FK_METRUL_TO_CRU.object_ivid
  and    the_tab.CLASSIFIER_RULE_REF is not null
  and    not exists (
             select null
             from   SDD_CRU foreign_tab
             where  the_tab.CLASSIFIER_RULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5087, action);
  end loop;
  return is_ok;
end FK_METRUL_TO_CRU;
/
create or replace function FK_METRUL_TO_RUL (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.NAMED_RULE_REF ref_value
  from   i$SDD_METRUL the_tab
  where  the_tab.ivid = FK_METRUL_TO_RUL.object_ivid
  and    the_tab.NAMED_RULE_REF is not null
  and    not exists (
             select null
             from   SDD_RUL foreign_tab
             where  the_tab.NAMED_RULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4833, action);
  end loop;
  return is_ok;
end FK_METRUL_TO_RUL;
/
create or replace function FK_METRUL_TO_SRU (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.STATE_RULE_REF ref_value
  from   i$SDD_METRUL the_tab
  where  the_tab.ivid = FK_METRUL_TO_SRU.object_ivid
  and    the_tab.STATE_RULE_REF is not null
  and    not exists (
             select null
             from   SDD_SRU foreign_tab
             where  the_tab.STATE_RULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5095, action);
  end loop;
  return is_ok;
end FK_METRUL_TO_SRU;
/
create or replace function FK_ITM_TO_PLM_cmd (irid number, ivid number) return boolean as
cursor bad_cur is
  select child_tab.irid child_irid, child_tab.types child_type
        ,parent_tab.ivid par_ivid, parent_tab.types par_type
  from   SDD_ITM child_tab, i$SDD_MOD parent_tab
  where  parent_tab.parent_ivid=FK_ITM_TO_PLM_cmd.ivid
  and    child_tab.PLSQL_MODULE_REF=parent_tab.IRID
  ;
  is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
   insert into I$SDD_INVALID_OBJECTS(object_irid,object_ivid,table_irid)
    select o.irid,o.ivid,o.table_irid
      from SDD_ITM child_tab
          ,i$SDD_MOD parent_tab
          ,I$SDD_OBJECT_VERSIONS o
     where parent_tab.parent_ivid=FK_ITM_TO_PLM_cmd.ivid
       and child_tab.PLSQL_MODULE_REF=parent_tab.IRID
       and child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(ref.par_ivid,ref.par_type,ref.child_irid,ref.child_type,'DEL');
  end loop;
  return is_ok;
end FK_ITM_TO_PLM_cmd;
/
create or replace function FK_ITM_TO_PLM_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_ITM child_tab
  where  child_tab.PLSQL_MODULE_REF=FK_ITM_TO_PLM_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_ITM child_tab, i$sdd_object_versions o
    where  child_tab.PLSQL_MODULE_REF=FK_ITM_TO_PLM_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_ITM_TO_PLM_d;
/
create or replace function FK_ITM_TO_PLM2_cmd (irid number, ivid number) return boolean as
cursor bad_cur is
  select child_tab.irid child_irid, child_tab.types child_type
        ,parent_tab.ivid par_ivid, parent_tab.types par_type
  from   SDD_ITM child_tab, i$SDD_MOD parent_tab
  where  parent_tab.parent_ivid=FK_ITM_TO_PLM2_cmd.ivid
  and    child_tab.CURSOR_REF=parent_tab.IRID
  ;
  is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
   insert into I$SDD_INVALID_OBJECTS(object_irid,object_ivid,table_irid)
    select o.irid,o.ivid,o.table_irid
      from SDD_ITM child_tab
          ,i$SDD_MOD parent_tab
          ,I$SDD_OBJECT_VERSIONS o
     where parent_tab.parent_ivid=FK_ITM_TO_PLM2_cmd.ivid
       and child_tab.CURSOR_REF=parent_tab.IRID
       and child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(ref.par_ivid,ref.par_type,ref.child_irid,ref.child_type,'DEL');
  end loop;
  return is_ok;
end FK_ITM_TO_PLM2_cmd;
/
create or replace function FK_ITM_TO_PLM2_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_ITM child_tab
  where  child_tab.CURSOR_REF=FK_ITM_TO_PLM2_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_ITM child_tab, i$sdd_object_versions o
    where  child_tab.CURSOR_REF=FK_ITM_TO_PLM2_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_ITM_TO_PLM2_d;
/
create or replace function FK_MODMOD_TO_MOD2_cmd (irid number, ivid number) return boolean as
cursor bad_cur is
  select child_tab.irid child_irid, child_tab.types child_type
        ,parent_tab.ivid par_ivid, parent_tab.types par_type
  from   SDD_MODMOD child_tab, i$SDD_MOD parent_tab
  where  parent_tab.parent_ivid=FK_MODMOD_TO_MOD2_cmd.ivid
  and    child_tab.CHILD_MODULE_REF=parent_tab.IRID
  ;
  is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
   insert into I$SDD_INVALID_OBJECTS(object_irid,object_ivid,table_irid)
    select o.irid,o.ivid,o.table_irid
      from SDD_MODMOD child_tab
          ,i$SDD_MOD parent_tab
          ,I$SDD_OBJECT_VERSIONS o
     where parent_tab.parent_ivid=FK_MODMOD_TO_MOD2_cmd.ivid
       and child_tab.CHILD_MODULE_REF=parent_tab.IRID
       and child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(ref.par_ivid,ref.par_type,ref.child_irid,ref.child_type,'DEL');
  end loop;
  return is_ok;
end FK_MODMOD_TO_MOD2_cmd;
/
create or replace function FK_MODMOD_TO_MOD2_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_MODMOD child_tab
  where  child_tab.CHILD_MODULE_REF=FK_MODMOD_TO_MOD2_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_MODMOD child_tab, i$sdd_object_versions o
    where  child_tab.CHILD_MODULE_REF=FK_MODMOD_TO_MOD2_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_MODMOD_TO_MOD2_d;
/
create or replace function FK_TRG_TO_PLM_cmd (irid number, ivid number) return boolean as
cursor bad_cur is
  select child_tab.irid child_irid, child_tab.types child_type
        ,parent_tab.ivid par_ivid, parent_tab.types par_type
  from   SDD_TRG child_tab, i$SDD_MOD parent_tab
  where  parent_tab.parent_ivid=FK_TRG_TO_PLM_cmd.ivid
  and    child_tab.PLSQL_MODULE_REF=parent_tab.IRID
  ;
  is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
   insert into I$SDD_INVALID_OBJECTS(object_irid,object_ivid,table_irid)
    select o.irid,o.ivid,o.table_irid
      from SDD_TRG child_tab
          ,i$SDD_MOD parent_tab
          ,I$SDD_OBJECT_VERSIONS o
     where parent_tab.parent_ivid=FK_TRG_TO_PLM_cmd.ivid
       and child_tab.PLSQL_MODULE_REF=parent_tab.IRID
       and child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(ref.par_ivid,ref.par_type,ref.child_irid,ref.child_type,'DEL');
  end loop;
  return is_ok;
end FK_TRG_TO_PLM_cmd;
/
create or replace function FK_TRG_TO_PLM_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_TRG child_tab
  where  child_tab.PLSQL_MODULE_REF=FK_TRG_TO_PLM_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_TRG child_tab, i$sdd_object_versions o
    where  child_tab.PLSQL_MODULE_REF=FK_TRG_TO_PLM_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_TRG_TO_PLM_d;
/
create or replace function SDD_MOD_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_MOD_cur is
    select *
    from   i$SDD_MOD the_tab
    where  the_tab.irid=SDD_MOD_ver.irid
    and    the_tab.ivid=SDD_MOD_ver.ivid;
  SDD_MOD_rec SDD_MOD_cur%ROWTYPE;
  cursor SDD_ARG_cur1 is
    select *
    from i$SDD_ARG the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_ARGITE_cur2 is
    select *
    from i$SDD_ARGITE the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_ATV_cur3 is
    select *
    from i$SDD_ATV the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_DAT_cur4 is
    select *
    from i$SDD_DAT the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_ITM_cur5 is
    select *
    from i$SDD_ITM the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_DSY_cur6 is
    select *
    from i$SDD_DSY the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_LVI_cur7 is
    select *
    from i$SDD_LVI the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_MCH_cur8 is
    select *
    from i$SDD_MCH the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_MCL_cur9 is
    select *
    from i$SDD_MCL the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_MCN_cur10 is
    select *
    from i$SDD_MCN the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_ACI_cur11 is
    select *
    from i$SDD_ACI the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_MODBUN_cur12 is
    select *
    from i$SDD_MODBUN the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_MODFUN_cur13 is
    select *
    from i$SDD_MODFUN the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_MODMOD_cur14 is
    select *
    from i$SDD_MODMOD the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_PVL_cur15 is
    select *
    from i$SDD_PVL the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_MODPGD_cur16 is
    select *
    from i$SDD_MODPGD the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_MUN_cur17 is
    select *
    from i$SDD_MUN the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_IGR_cur18 is
    select *
    from i$SDD_IGR the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_ITE_cur19 is
    select *
    from i$SDD_ITE the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_MTI_cur20 is
    select *
    from i$SDD_MTI the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_CNU_cur21 is
    select *
    from i$SDD_CNU the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_SQS_cur22 is
    select *
    from i$SDD_SQS the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_PGD_cur23 is
    select *
    from i$SDD_PGD the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
  cursor SDD_WIN_cur24 is
    select *
    from i$SDD_WIN the_tab
    where the_tab.parent_ivid=SDD_MOD_ver.ivid;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_MOD_cur;
  fetch SDD_MOD_cur into SDD_MOD_rec;
  close SDD_MOD_cur;
  insert into i$SDD_MOD
  values (
    SDD_MOD_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_MOD_rec.pac_ref     -- pac_ref
   ,SDD_MOD_rec.parent_ivid -- parent_ivid
   ,SDD_MOD_rec.TYPES
   ,SDD_MOD_rec.ELEMENT_TYPE_NAME
   ,SDD_MOD_rec.DATE_CREATED
   ,SDD_MOD_rec.CREATED_BY
   ,SDD_MOD_rec.DATE_CHANGED
   ,SDD_MOD_rec.CHANGED_BY
   ,SDD_MOD_rec.NOTM
   ,SDD_MOD_rec.SHORT_NAME
   ,SDD_MOD_rec.NAME
   ,SDD_MOD_rec.LANGUAGE_REF
   ,SDD_MOD_rec.PURPOSE
   ,SDD_MOD_rec.JAVA_MODULE_TYPE
   ,SDD_MOD_rec.PLSQL_MODULE_TYPE
   ,SDD_MOD_rec.IMPLEMENTATION_NAME
   ,SDD_MOD_rec.SCOPE
   ,SDD_MOD_rec.JAVA_RETURN_TYPE
   ,SDD_MOD_rec.ORACLE_OBJECT_TYPE_REF
   ,SDD_MOD_rec.GENERAL_MODULE_TYPE
   ,SDD_MOD_rec.TYPE_MEMBER_ORDERING
   ,SDD_MOD_rec.TOP_TITLE
   ,SDD_MOD_rec.BOTTOM_TITLE
   ,SDD_MOD_rec.SHORT_TITLE
   ,SDD_MOD_rec.FORMAT
   ,SDD_MOD_rec.COMPLETION_STATUS
   ,SDD_MOD_rec.CANDIDATE_FLAG
   ,SDD_MOD_rec.PREVENT_GENERATION_FLAG
   ,SDD_MOD_rec.SIZE_OF_MODULE
   ,SDD_MOD_rec.COMPLEXITY
   ,SDD_MOD_rec.PROJECT_CODE
   ,SDD_MOD_rec.ACTIVITY_CODE
   ,SDD_MOD_rec.TASK_CODE
   ,SDD_MOD_rec.ESTIMATE
   ,SDD_MOD_rec.MODULE_TYPE
   ,SDD_MOD_rec.ESTIMATE_UNITS
   ,SDD_MOD_rec.TOP_LEVEL_FLAG
   ,SDD_MOD_rec.COMMAND_LINE
   ,SDD_MOD_rec.REPEATABLE_FLAG
   ,SDD_MOD_rec.RETURN_TYPE
   ,SDD_MOD_rec.ORACLE_TYPE_REF
   ,SDD_MOD_rec.RUNTIME_PATHNAME
   ,SDD_MOD_rec.WNDS_FLAG
   ,SDD_MOD_rec.WNPS_FLAG
   ,SDD_MOD_rec.RNDS_FLAG
   ,SDD_MOD_rec.RNPS_FLAG
   ,SDD_MOD_rec.FREE_FORMAT_TEXT_FLAG
   ,SDD_MOD_rec.SOURCE_PATHNAME
   ,SDD_MOD_rec.HELP_FILE_NAME
   ,SDD_MOD_rec.HELP_GRAPHIC_FILE_NAME
   ,SDD_MOD_rec.JAVA_MODULE_REF
   ,SDD_MOD_rec.JAVA_METHOD
   ,SDD_MOD_rec.JAVA_PARAMETER_LIST
   ,SDD_MOD_rec.HELP_CONTEXT_ID_PREFIX
   ,SDD_MOD_rec.USRX0
   ,SDD_MOD_rec.USRX1
   ,SDD_MOD_rec.USRX2
   ,SDD_MOD_rec.USRX3
   ,SDD_MOD_rec.USRX4
   ,SDD_MOD_rec.USRX5
   ,SDD_MOD_rec.USRX6
   ,SDD_MOD_rec.USRX7
   ,SDD_MOD_rec.USRX8
   ,SDD_MOD_rec.USRX9
   ,SDD_MOD_rec.USRX10
   ,SDD_MOD_rec.USRX11
   ,SDD_MOD_rec.USRX12
   ,SDD_MOD_rec.USRX13
   ,SDD_MOD_rec.USRX14
   ,SDD_MOD_rec.USRX15
   ,SDD_MOD_rec.USRX16
   ,SDD_MOD_rec.USRX17
   ,SDD_MOD_rec.USRX18
   ,SDD_MOD_rec.USRX19
  );
  jr_reg_ver.vercopy_dependencies(SDD_MOD_ver.irid, SDD_MOD_ver.ivid, new_ivid, null, copy_dependencies);
  for SDD_ARG_rec1 in SDD_ARG_cur1 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ARG
    values (
       SDD_ARG_rec1.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ARG_rec1.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ARG_rec1.TYPES
     , SDD_ARG_rec1.ELEMENT_TYPE_NAME
     , SDD_ARG_rec1.DATE_CREATED
     , SDD_ARG_rec1.CREATED_BY
     , SDD_ARG_rec1.DATE_CHANGED
     , SDD_ARG_rec1.CHANGED_BY
     , SDD_ARG_rec1.NOTM
     , SDD_ARG_rec1.GENERAL_MODULE_REF
     , SDD_ARG_rec1.PLSQL_MODULE_REF
     , SDD_ARG_rec1.NAME
     , SDD_ARG_rec1.INPUT_OUTPUT_IDENTIFIER
     , SDD_ARG_rec1.POSITION
     , SDD_ARG_rec1.DOMAIN_REF
     , SDD_ARG_rec1.DATASTRUCTURE_REF
     , SDD_ARG_rec1.COLUMN_REF
     , SDD_ARG_rec1.TABLE_DEFINITION_REF
     , SDD_ARG_rec1.ORACLE_TYPE_REF
     , SDD_ARG_rec1.DATATYPE
     , SDD_ARG_rec1.LENGTH
     , SDD_ARG_rec1.SCALE
     , SDD_ARG_rec1.DEFAULT_VALUE
     , SDD_ARG_rec1.DEFAULT_VALUE_TYPE
     , SDD_ARG_rec1.OPTIONAL_FLAG
     , SDD_ARG_rec1.DISPLAY_FLAG
     , SDD_ARG_rec1.PROMPT
     , SDD_ARG_rec1.SOFT_LOV
     , SDD_ARG_rec1.SUGGESTION_LIST_FLAG
     , SDD_ARG_rec1.INPUT_MASK
     , SDD_ARG_rec1.SUBSTITUTION_VARIABLE
     , SDD_ARG_rec1.REMARK
     , SDD_ARG_rec1.ATTRIBUTE_OR_DATAITEM
     , SDD_ARG_rec1.MODULE_ARGUMENT_FOR
     , SDD_ARG_rec1.MODULE_TYPE_FOR
     , SDD_ARG_rec1.USRX0
     , SDD_ARG_rec1.USRX1
     , SDD_ARG_rec1.USRX2
     , SDD_ARG_rec1.USRX3
     , SDD_ARG_rec1.USRX4
     , SDD_ARG_rec1.USRX5
     , SDD_ARG_rec1.USRX6
     , SDD_ARG_rec1.USRX7
     , SDD_ARG_rec1.USRX8
     , SDD_ARG_rec1.USRX9
     , SDD_ARG_rec1.USRX10
     , SDD_ARG_rec1.USRX11
     , SDD_ARG_rec1.USRX12
     , SDD_ARG_rec1.USRX13
     , SDD_ARG_rec1.USRX14
     , SDD_ARG_rec1.USRX15
     , SDD_ARG_rec1.USRX16
     , SDD_ARG_rec1.USRX17
     , SDD_ARG_rec1.USRX18
     , SDD_ARG_rec1.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ARG_rec1.irid, SDD_ARG_rec1.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_ARGITE_rec2 in SDD_ARGITE_cur2 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ARGITE
    values (
       SDD_ARGITE_rec2.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ARGITE_rec2.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ARGITE_rec2.TYPES
     , SDD_ARGITE_rec2.ELEMENT_TYPE_NAME
     , SDD_ARGITE_rec2.DATE_CREATED
     , SDD_ARGITE_rec2.CREATED_BY
     , SDD_ARGITE_rec2.DATE_CHANGED
     , SDD_ARGITE_rec2.CHANGED_BY
     , SDD_ARGITE_rec2.NOTM
     , SDD_ARGITE_rec2.MODULE_ARGUMENT_REF
     , SDD_ARGITE_rec2.ITEM_REF
     , SDD_ARGITE_rec2.ARGUMENT_OPERATOR
     , SDD_ARGITE_rec2.SQL_QUERY_CLAUSE
     , SDD_ARGITE_rec2.USE_PRIOR_ROW_FLAG
     , SDD_ARGITE_rec2.USRX0
     , SDD_ARGITE_rec2.USRX1
     , SDD_ARGITE_rec2.USRX2
     , SDD_ARGITE_rec2.USRX3
     , SDD_ARGITE_rec2.USRX4
     , SDD_ARGITE_rec2.USRX5
     , SDD_ARGITE_rec2.USRX6
     , SDD_ARGITE_rec2.USRX7
     , SDD_ARGITE_rec2.USRX8
     , SDD_ARGITE_rec2.USRX9
     , SDD_ARGITE_rec2.USRX10
     , SDD_ARGITE_rec2.USRX11
     , SDD_ARGITE_rec2.USRX12
     , SDD_ARGITE_rec2.USRX13
     , SDD_ARGITE_rec2.USRX14
     , SDD_ARGITE_rec2.USRX15
     , SDD_ARGITE_rec2.USRX16
     , SDD_ARGITE_rec2.USRX17
     , SDD_ARGITE_rec2.USRX18
     , SDD_ARGITE_rec2.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ARGITE_rec2.irid, SDD_ARGITE_rec2.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_ATV_rec3 in SDD_ATV_cur3 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ATV
    values (
       SDD_ATV_rec3.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ATV_rec3.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ATV_rec3.TYPES
     , SDD_ATV_rec3.ELEMENT_TYPE_NAME
     , SDD_ATV_rec3.DATE_CREATED
     , SDD_ATV_rec3.CREATED_BY
     , SDD_ATV_rec3.DATE_CHANGED
     , SDD_ATV_rec3.CHANGED_BY
     , SDD_ATV_rec3.NOTM
     , SDD_ATV_rec3.ATTRIBUTE_REF
     , SDD_ATV_rec3.DOMAIN_REF
     , SDD_ATV_rec3.COLUMN_REF
     , SDD_ATV_rec3.MODULE_ARGUMENT_REF
     , SDD_ATV_rec3.UNBOUND_ITEM_REF
     , SDD_ATV_rec3.LOW_VALUE
     , SDD_ATV_rec3.HIGH_VALUE
     , SDD_ATV_rec3.ABBREVIATION
     , SDD_ATV_rec3.LOW_VALUE_TYPE
     , SDD_ATV_rec3.MEANING
     , SDD_ATV_rec3.HIGH_VALUE_TYPE
     , SDD_ATV_rec3.RADIO_SEQUENCE
     , SDD_ATV_rec3.ATTRIBUTE_VALUE_FOR
     , SDD_ATV_rec3.USRX0
     , SDD_ATV_rec3.USRX1
     , SDD_ATV_rec3.USRX2
     , SDD_ATV_rec3.USRX3
     , SDD_ATV_rec3.USRX4
     , SDD_ATV_rec3.USRX5
     , SDD_ATV_rec3.USRX6
     , SDD_ATV_rec3.USRX7
     , SDD_ATV_rec3.USRX8
     , SDD_ATV_rec3.USRX9
     , SDD_ATV_rec3.USRX10
     , SDD_ATV_rec3.USRX11
     , SDD_ATV_rec3.USRX12
     , SDD_ATV_rec3.USRX13
     , SDD_ATV_rec3.USRX14
     , SDD_ATV_rec3.USRX15
     , SDD_ATV_rec3.USRX16
     , SDD_ATV_rec3.USRX17
     , SDD_ATV_rec3.USRX18
     , SDD_ATV_rec3.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ATV_rec3.irid, SDD_ATV_rec3.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_DAT_rec4 in SDD_DAT_cur4 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DAT
    values (
       SDD_DAT_rec4.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DAT_rec4.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DAT_rec4.TYPES
     , SDD_DAT_rec4.ELEMENT_TYPE_NAME
     , SDD_DAT_rec4.DATE_CREATED
     , SDD_DAT_rec4.CREATED_BY
     , SDD_DAT_rec4.DATE_CHANGED
     , SDD_DAT_rec4.CHANGED_BY
     , SDD_DAT_rec4.NOTM
     , SDD_DAT_rec4.PLSQL_MODULE_REF
     , SDD_DAT_rec4.NAME
     , SDD_DAT_rec4.DATASTRUCTURE_TYPE
     , SDD_DAT_rec4.SCOPE
     , SDD_DAT_rec4.REMARK
     , SDD_DAT_rec4.SEQUENCE
     , SDD_DAT_rec4.USRX0
     , SDD_DAT_rec4.USRX1
     , SDD_DAT_rec4.USRX2
     , SDD_DAT_rec4.USRX3
     , SDD_DAT_rec4.USRX4
     , SDD_DAT_rec4.USRX5
     , SDD_DAT_rec4.USRX6
     , SDD_DAT_rec4.USRX7
     , SDD_DAT_rec4.USRX8
     , SDD_DAT_rec4.USRX9
     , SDD_DAT_rec4.USRX10
     , SDD_DAT_rec4.USRX11
     , SDD_DAT_rec4.USRX12
     , SDD_DAT_rec4.USRX13
     , SDD_DAT_rec4.USRX14
     , SDD_DAT_rec4.USRX15
     , SDD_DAT_rec4.USRX16
     , SDD_DAT_rec4.USRX17
     , SDD_DAT_rec4.USRX18
     , SDD_DAT_rec4.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DAT_rec4.irid, SDD_DAT_rec4.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_ITM_rec5 in SDD_ITM_cur5 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ITM
    values (
       SDD_ITM_rec5.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ITM_rec5.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ITM_rec5.TYPES
     , SDD_ITM_rec5.ELEMENT_TYPE_NAME
     , SDD_ITM_rec5.DATE_CREATED
     , SDD_ITM_rec5.CREATED_BY
     , SDD_ITM_rec5.DATE_CHANGED
     , SDD_ITM_rec5.CHANGED_BY
     , SDD_ITM_rec5.NOTM
     , SDD_ITM_rec5.DATASTRUCTURE_REF
     , SDD_ITM_rec5.NAME
     , SDD_ITM_rec5.SEQUENCE
     , SDD_ITM_rec5.DOMAIN_REF
     , SDD_ITM_rec5.TABLE_DEFINITION_REF
     , SDD_ITM_rec5.COLUMN_REF
     , SDD_ITM_rec5.ORACLE_TYPE_REF
     , SDD_ITM_rec5.DATASTRUCTURE_REF2
     , SDD_ITM_rec5.PROGRAM_DATUM_REF
     , SDD_ITM_rec5.PLSQL_MODULE_REF
     , SDD_ITM_rec5.CURSOR_REF
     , SDD_ITM_rec5.DATATYPE
     , SDD_ITM_rec5.MAXIMUM_LENGTH
     , SDD_ITM_rec5.SCALE
     , SDD_ITM_rec5.DEFAULT_VALUE
     , SDD_ITM_rec5.DEFAULT_VALUE_TYPE
     , SDD_ITM_rec5.NULLS
     , SDD_ITM_rec5.ITEM_TYPE
     , SDD_ITM_rec5.CQA_REF
     , SDD_ITM_rec5.USRX0
     , SDD_ITM_rec5.USRX1
     , SDD_ITM_rec5.USRX2
     , SDD_ITM_rec5.USRX3
     , SDD_ITM_rec5.USRX4
     , SDD_ITM_rec5.USRX5
     , SDD_ITM_rec5.USRX6
     , SDD_ITM_rec5.USRX7
     , SDD_ITM_rec5.USRX8
     , SDD_ITM_rec5.USRX9
     , SDD_ITM_rec5.USRX10
     , SDD_ITM_rec5.USRX11
     , SDD_ITM_rec5.USRX12
     , SDD_ITM_rec5.USRX13
     , SDD_ITM_rec5.USRX14
     , SDD_ITM_rec5.USRX15
     , SDD_ITM_rec5.USRX16
     , SDD_ITM_rec5.USRX17
     , SDD_ITM_rec5.USRX18
     , SDD_ITM_rec5.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ITM_rec5.irid, SDD_ITM_rec5.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_DSY_rec6 in SDD_DSY_cur6 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DSY
    values (
       SDD_DSY_rec6.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DSY_rec6.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DSY_rec6.TYPES
     , SDD_DSY_rec6.ELEMENT_TYPE_NAME
     , SDD_DSY_rec6.DATE_CREATED
     , SDD_DSY_rec6.CREATED_BY
     , SDD_DSY_rec6.DATE_CHANGED
     , SDD_DSY_rec6.CHANGED_BY
     , SDD_DSY_rec6.NOTM
     , SDD_DSY_rec6.TABLE_DEFINITION_REF
     , SDD_DSY_rec6.VIEW_DEFINITION_REF
     , SDD_DSY_rec6.SNAPSHOT_DEFINITION_REF
     , SDD_DSY_rec6.SEQUENCE_REF
     , SDD_DSY_rec6.PLSQL_MODULE_REF
     , SDD_DSY_rec6.JAVA_MODULE_REF
     , SDD_DSY_rec6.NAME
     , SDD_DSY_rec6.SCOPE
     , SDD_DSY_rec6.COMPLETE_FLAG
     , SDD_DSY_rec6.SYNONYM_FOR
     , SDD_DSY_rec6.USRX0
     , SDD_DSY_rec6.USRX1
     , SDD_DSY_rec6.USRX2
     , SDD_DSY_rec6.USRX3
     , SDD_DSY_rec6.USRX4
     , SDD_DSY_rec6.USRX5
     , SDD_DSY_rec6.USRX6
     , SDD_DSY_rec6.USRX7
     , SDD_DSY_rec6.USRX8
     , SDD_DSY_rec6.USRX9
     , SDD_DSY_rec6.USRX10
     , SDD_DSY_rec6.USRX11
     , SDD_DSY_rec6.USRX12
     , SDD_DSY_rec6.USRX13
     , SDD_DSY_rec6.USRX14
     , SDD_DSY_rec6.USRX15
     , SDD_DSY_rec6.USRX16
     , SDD_DSY_rec6.USRX17
     , SDD_DSY_rec6.USRX18
     , SDD_DSY_rec6.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DSY_rec6.irid, SDD_DSY_rec6.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_LVI_rec7 in SDD_LVI_cur7 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_LVI
    values (
       SDD_LVI_rec7.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_LVI_rec7.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_LVI_rec7.TYPES
     , SDD_LVI_rec7.ELEMENT_TYPE_NAME
     , SDD_LVI_rec7.DATE_CREATED
     , SDD_LVI_rec7.CREATED_BY
     , SDD_LVI_rec7.DATE_CHANGED
     , SDD_LVI_rec7.CHANGED_BY
     , SDD_LVI_rec7.NOTM
     , SDD_LVI_rec7.GENERAL_MODULE_REF
     , SDD_LVI_rec7.LIST_OF_VALUES_REF
     , SDD_LVI_rec7.USAGE_SEQUENCE
     , SDD_LVI_rec7.ITEM_REF
     , SDD_LVI_rec7.RETURN_LIST
     , SDD_LVI_rec7.LONG_LIST_FLAG
     , SDD_LVI_rec7.USED_FOR
     , SDD_LVI_rec7.RESTRICTION_CLAUSE
     , SDD_LVI_rec7.REQ_VIEW_POSX
     , SDD_LVI_rec7.REQ_VIEW_POSY
     , SDD_LVI_rec7.DISPLAY_TITLE_OVERRIDE
     , SDD_LVI_rec7.USRX0
     , SDD_LVI_rec7.USRX1
     , SDD_LVI_rec7.USRX2
     , SDD_LVI_rec7.USRX3
     , SDD_LVI_rec7.USRX4
     , SDD_LVI_rec7.USRX5
     , SDD_LVI_rec7.USRX6
     , SDD_LVI_rec7.USRX7
     , SDD_LVI_rec7.USRX8
     , SDD_LVI_rec7.USRX9
     , SDD_LVI_rec7.USRX10
     , SDD_LVI_rec7.USRX11
     , SDD_LVI_rec7.USRX12
     , SDD_LVI_rec7.USRX13
     , SDD_LVI_rec7.USRX14
     , SDD_LVI_rec7.USRX15
     , SDD_LVI_rec7.USRX16
     , SDD_LVI_rec7.USRX17
     , SDD_LVI_rec7.USRX18
     , SDD_LVI_rec7.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_LVI_rec7.irid, SDD_LVI_rec7.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_MCH_rec8 in SDD_MCH_cur8 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_MCH
    values (
       SDD_MCH_rec8.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_MCH_rec8.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_MCH_rec8.TYPES
     , SDD_MCH_rec8.ELEMENT_TYPE_NAME
     , SDD_MCH_rec8.DATE_CREATED
     , SDD_MCH_rec8.CREATED_BY
     , SDD_MCH_rec8.DATE_CHANGED
     , SDD_MCH_rec8.CHANGED_BY
     , SDD_MCH_rec8.NOTM
     , SDD_MCH_rec8.MODULE_REF
     , SDD_MCH_rec8.CHANGE_REF
     , SDD_MCH_rec8.DEVELOPER
     , SDD_MCH_rec8.DEVELOPMENT_DIR
     , SDD_MCH_rec8.PRODUCT_VERSION
     , SDD_MCH_rec8.DATE_OUT
     , SDD_MCH_rec8.DATE_COMPLETE
     , SDD_MCH_rec8.DESCRIPTION
     , SDD_MCH_rec8.DATE_TRANSFERRED
     , SDD_MCH_rec8.TRANSFERRED_BY
     , SDD_MCH_rec8.USRX0
     , SDD_MCH_rec8.USRX1
     , SDD_MCH_rec8.USRX2
     , SDD_MCH_rec8.USRX3
     , SDD_MCH_rec8.USRX4
     , SDD_MCH_rec8.USRX5
     , SDD_MCH_rec8.USRX6
     , SDD_MCH_rec8.USRX7
     , SDD_MCH_rec8.USRX8
     , SDD_MCH_rec8.USRX9
     , SDD_MCH_rec8.USRX10
     , SDD_MCH_rec8.USRX11
     , SDD_MCH_rec8.USRX12
     , SDD_MCH_rec8.USRX13
     , SDD_MCH_rec8.USRX14
     , SDD_MCH_rec8.USRX15
     , SDD_MCH_rec8.USRX16
     , SDD_MCH_rec8.USRX17
     , SDD_MCH_rec8.USRX18
     , SDD_MCH_rec8.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_MCH_rec8.irid, SDD_MCH_rec8.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_MCL_rec9 in SDD_MCL_cur9 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_MCL
    values (
       SDD_MCL_rec9.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_MCL_rec9.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_MCL_rec9.TYPES
     , SDD_MCL_rec9.ELEMENT_TYPE_NAME
     , SDD_MCL_rec9.DATE_CREATED
     , SDD_MCL_rec9.CREATED_BY
     , SDD_MCL_rec9.DATE_CHANGED
     , SDD_MCL_rec9.CHANGED_BY
     , SDD_MCL_rec9.NOTM
     , SDD_MCL_rec9.MCN_REF_FROM
     , SDD_MCL_rec9.TABLE_USAGE_REF_FROM
     , SDD_MCL_rec9.MCN_REF_TO
     , SDD_MCL_rec9.TABLE_USAGE_REF_TO
     , SDD_MCL_rec9.JOIN_CONSTRAINT_REF
     , SDD_MCL_rec9.PRIMARY_KEY_REF
     , SDD_MCL_rec9.FK_ON_FROM_COMPONENT_FLAG
     , SDD_MCL_rec9.SQL_QUERY_CLAUSE
     , SDD_MCL_rec9.MODULE_COMPONENT_LINK_TYPE
     , SDD_MCL_rec9.MODULE_REF_FROM
     , SDD_MCL_rec9.MODULE_REF_TO
     , SDD_MCL_rec9.KEY_BASED_LINK_VIA
     , SDD_MCL_rec9.USRX0
     , SDD_MCL_rec9.USRX1
     , SDD_MCL_rec9.USRX2
     , SDD_MCL_rec9.USRX3
     , SDD_MCL_rec9.USRX4
     , SDD_MCL_rec9.USRX5
     , SDD_MCL_rec9.USRX6
     , SDD_MCL_rec9.USRX7
     , SDD_MCL_rec9.USRX8
     , SDD_MCL_rec9.USRX9
     , SDD_MCL_rec9.USRX10
     , SDD_MCL_rec9.USRX11
     , SDD_MCL_rec9.USRX12
     , SDD_MCL_rec9.USRX13
     , SDD_MCL_rec9.USRX14
     , SDD_MCL_rec9.USRX15
     , SDD_MCL_rec9.USRX16
     , SDD_MCL_rec9.USRX17
     , SDD_MCL_rec9.USRX18
     , SDD_MCL_rec9.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_MCL_rec9.irid, SDD_MCL_rec9.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_MCN_rec10 in SDD_MCN_cur10 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_MCN
    values (
       SDD_MCN_rec10.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_MCN_rec10.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_MCN_rec10.TYPES
     , SDD_MCN_rec10.ELEMENT_TYPE_NAME
     , SDD_MCN_rec10.DATE_CREATED
     , SDD_MCN_rec10.CREATED_BY
     , SDD_MCN_rec10.DATE_CHANGED
     , SDD_MCN_rec10.CHANGED_BY
     , SDD_MCN_rec10.NOTM
     , SDD_MCN_rec10.GENERAL_MODULE_REF
     , SDD_MCN_rec10.MODULE_COMPONENT_REF
     , SDD_MCN_rec10.SUBCOMPONENT_REF
     , SDD_MCN_rec10.USAGE_SEQUENCE
     , SDD_MCN_rec10.WINDOW_REF
     , SDD_MCN_rec10.RIGHT_OF_MCN_REF
     , SDD_MCN_rec10.REQ_PLACEMENT
     , SDD_MCN_rec10.PLACEMENT_ITEM
     , SDD_MCN_rec10.REQ_VIEW_POSX
     , SDD_MCN_rec10.REQ_VIEW_POSY
     , SDD_MCN_rec10.TAB_SCOPE
     , SDD_MCN_rec10.PARENT_MCN_REF
     , SDD_MCN_rec10.USRX0
     , SDD_MCN_rec10.USRX1
     , SDD_MCN_rec10.USRX2
     , SDD_MCN_rec10.USRX3
     , SDD_MCN_rec10.USRX4
     , SDD_MCN_rec10.USRX5
     , SDD_MCN_rec10.USRX6
     , SDD_MCN_rec10.USRX7
     , SDD_MCN_rec10.USRX8
     , SDD_MCN_rec10.USRX9
     , SDD_MCN_rec10.USRX10
     , SDD_MCN_rec10.USRX11
     , SDD_MCN_rec10.USRX12
     , SDD_MCN_rec10.USRX13
     , SDD_MCN_rec10.USRX14
     , SDD_MCN_rec10.USRX15
     , SDD_MCN_rec10.USRX16
     , SDD_MCN_rec10.USRX17
     , SDD_MCN_rec10.USRX18
     , SDD_MCN_rec10.USRX19
     , SDD_MCN_rec10.MCN_FOR
    );
  jr_reg_ver.vercopy_dependencies(SDD_MCN_rec10.irid, SDD_MCN_rec10.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_ACI_rec11 in SDD_ACI_cur11 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ACI
    values (
       SDD_ACI_rec11.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ACI_rec11.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ACI_rec11.TYPES
     , SDD_ACI_rec11.ELEMENT_TYPE_NAME
     , SDD_ACI_rec11.DATE_CREATED
     , SDD_ACI_rec11.CREATED_BY
     , SDD_ACI_rec11.DATE_CHANGED
     , SDD_ACI_rec11.CHANGED_BY
     , SDD_ACI_rec11.NOTM
     , SDD_ACI_rec11.MCN_REF
     , SDD_ACI_rec11.WINDOW_REF
     , SDD_ACI_rec11.NAME
     , SDD_ACI_rec11.GENERATOR_ITEM_TYPE
     , SDD_ACI_rec11.USAGE_SEQUENCE
     , SDD_ACI_rec11.DEFAULT_FLAG
     , SDD_ACI_rec11.MCN_REF_TO
     , SDD_ACI_rec11.ENABLE_ON_DB_RECORD_FLAG
     , SDD_ACI_rec11.IMPLEMENTATION_ITEM
     , SDD_ACI_rec11.MODULE_NETWORK_REF
     , SDD_ACI_rec11.PROMPT
     , SDD_ACI_rec11.ICON_NAME
     , SDD_ACI_rec11.CREATE_BUTTON_FLAG
     , SDD_ACI_rec11.BUTTON_HEIGHT
     , SDD_ACI_rec11.BUTTON_WIDTH
     , SDD_ACI_rec11.CREATE_MENU_ITEM_FLAG
     , SDD_ACI_rec11.HINT_TEXT
     , SDD_ACI_rec11.ACTION_ITEM_TYPE
     , SDD_ACI_rec11.ACTION_ITEM_FOR
     , SDD_ACI_rec11.NAVIGATION_TO
     , SDD_ACI_rec11.USRX0
     , SDD_ACI_rec11.USRX1
     , SDD_ACI_rec11.USRX2
     , SDD_ACI_rec11.USRX3
     , SDD_ACI_rec11.USRX4
     , SDD_ACI_rec11.USRX5
     , SDD_ACI_rec11.USRX6
     , SDD_ACI_rec11.USRX7
     , SDD_ACI_rec11.USRX8
     , SDD_ACI_rec11.USRX9
     , SDD_ACI_rec11.USRX10
     , SDD_ACI_rec11.USRX11
     , SDD_ACI_rec11.USRX12
     , SDD_ACI_rec11.USRX13
     , SDD_ACI_rec11.USRX14
     , SDD_ACI_rec11.USRX15
     , SDD_ACI_rec11.USRX16
     , SDD_ACI_rec11.USRX17
     , SDD_ACI_rec11.USRX18
     , SDD_ACI_rec11.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ACI_rec11.irid, SDD_ACI_rec11.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_MODBUN_rec12 in SDD_MODBUN_cur12 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_MODBUN
    values (
       SDD_MODBUN_rec12.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_MODBUN_rec12.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_MODBUN_rec12.TYPES
     , SDD_MODBUN_rec12.ELEMENT_TYPE_NAME
     , SDD_MODBUN_rec12.DATE_CREATED
     , SDD_MODBUN_rec12.CREATED_BY
     , SDD_MODBUN_rec12.DATE_CHANGED
     , SDD_MODBUN_rec12.CHANGED_BY
     , SDD_MODBUN_rec12.NOTM
     , SDD_MODBUN_rec12.MODULE_REF
     , SDD_MODBUN_rec12.BUSINESS_UNIT_REF
     , SDD_MODBUN_rec12.REMARK
     , SDD_MODBUN_rec12.USRX0
     , SDD_MODBUN_rec12.USRX1
     , SDD_MODBUN_rec12.USRX2
     , SDD_MODBUN_rec12.USRX3
     , SDD_MODBUN_rec12.USRX4
     , SDD_MODBUN_rec12.USRX5
     , SDD_MODBUN_rec12.USRX6
     , SDD_MODBUN_rec12.USRX7
     , SDD_MODBUN_rec12.USRX8
     , SDD_MODBUN_rec12.USRX9
     , SDD_MODBUN_rec12.USRX10
     , SDD_MODBUN_rec12.USRX11
     , SDD_MODBUN_rec12.USRX12
     , SDD_MODBUN_rec12.USRX13
     , SDD_MODBUN_rec12.USRX14
     , SDD_MODBUN_rec12.USRX15
     , SDD_MODBUN_rec12.USRX16
     , SDD_MODBUN_rec12.USRX17
     , SDD_MODBUN_rec12.USRX18
     , SDD_MODBUN_rec12.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_MODBUN_rec12.irid, SDD_MODBUN_rec12.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_MODFUN_rec13 in SDD_MODFUN_cur13 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_MODFUN
    values (
       SDD_MODFUN_rec13.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_MODFUN_rec13.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_MODFUN_rec13.TYPES
     , SDD_MODFUN_rec13.ELEMENT_TYPE_NAME
     , SDD_MODFUN_rec13.DATE_CREATED
     , SDD_MODFUN_rec13.CREATED_BY
     , SDD_MODFUN_rec13.DATE_CHANGED
     , SDD_MODFUN_rec13.CHANGED_BY
     , SDD_MODFUN_rec13.NOTM
     , SDD_MODFUN_rec13.MODULE_REF
     , SDD_MODFUN_rec13.FUNCTION_REF
     , SDD_MODFUN_rec13.REMARK
     , SDD_MODFUN_rec13.USRX0
     , SDD_MODFUN_rec13.USRX1
     , SDD_MODFUN_rec13.USRX2
     , SDD_MODFUN_rec13.USRX3
     , SDD_MODFUN_rec13.USRX4
     , SDD_MODFUN_rec13.USRX5
     , SDD_MODFUN_rec13.USRX6
     , SDD_MODFUN_rec13.USRX7
     , SDD_MODFUN_rec13.USRX8
     , SDD_MODFUN_rec13.USRX9
     , SDD_MODFUN_rec13.USRX10
     , SDD_MODFUN_rec13.USRX11
     , SDD_MODFUN_rec13.USRX12
     , SDD_MODFUN_rec13.USRX13
     , SDD_MODFUN_rec13.USRX14
     , SDD_MODFUN_rec13.USRX15
     , SDD_MODFUN_rec13.USRX16
     , SDD_MODFUN_rec13.USRX17
     , SDD_MODFUN_rec13.USRX18
     , SDD_MODFUN_rec13.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_MODFUN_rec13.irid, SDD_MODFUN_rec13.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_MODMOD_rec14 in SDD_MODMOD_cur14 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_MODMOD
    values (
       SDD_MODMOD_rec14.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_MODMOD_rec14.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_MODMOD_rec14.TYPES
     , SDD_MODMOD_rec14.ELEMENT_TYPE_NAME
     , SDD_MODMOD_rec14.DATE_CREATED
     , SDD_MODMOD_rec14.CREATED_BY
     , SDD_MODMOD_rec14.DATE_CHANGED
     , SDD_MODMOD_rec14.CHANGED_BY
     , SDD_MODMOD_rec14.NOTM
     , SDD_MODMOD_rec14.PARENT_MODULE_REF
     , SDD_MODMOD_rec14.CHILD_MODULE_REF
     , SDD_MODMOD_rec14.CALLED_SEQUENCE
     , SDD_MODMOD_rec14.METHOD
     , SDD_MODMOD_rec14.USRX0
     , SDD_MODMOD_rec14.USRX1
     , SDD_MODMOD_rec14.USRX2
     , SDD_MODMOD_rec14.USRX3
     , SDD_MODMOD_rec14.USRX4
     , SDD_MODMOD_rec14.USRX5
     , SDD_MODMOD_rec14.USRX6
     , SDD_MODMOD_rec14.USRX7
     , SDD_MODMOD_rec14.USRX8
     , SDD_MODMOD_rec14.USRX9
     , SDD_MODMOD_rec14.USRX10
     , SDD_MODMOD_rec14.USRX11
     , SDD_MODMOD_rec14.USRX12
     , SDD_MODMOD_rec14.USRX13
     , SDD_MODMOD_rec14.USRX14
     , SDD_MODMOD_rec14.USRX15
     , SDD_MODMOD_rec14.USRX16
     , SDD_MODMOD_rec14.USRX17
     , SDD_MODMOD_rec14.USRX18
     , SDD_MODMOD_rec14.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_MODMOD_rec14.irid, SDD_MODMOD_rec14.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_PVL_rec15 in SDD_PVL_cur15 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_PVL
    values (
       SDD_PVL_rec15.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_PVL_rec15.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_PVL_rec15.TYPES
     , SDD_PVL_rec15.ELEMENT_TYPE_NAME
     , SDD_PVL_rec15.DATE_CREATED
     , SDD_PVL_rec15.NAME
     , SDD_PVL_rec15.CREATED_BY
     , SDD_PVL_rec15.DATE_CHANGED
     , SDD_PVL_rec15.CHANGED_BY
     , SDD_PVL_rec15.NOTM
     , SDD_PVL_rec15.MODULE_NETWORK_REF
     , SDD_PVL_rec15.CALLED_ARGUMENT_REF
     , SDD_PVL_rec15.MODULE_ARGUMENT_REF
     , SDD_PVL_rec15.ITEM_REF
     , SDD_PVL_rec15.VALUE
     , SDD_PVL_rec15.CALLED_ARGUMENT_VALUE_FROM
     , SDD_PVL_rec15.PASSED_VALUE_TYPE
     , SDD_PVL_rec15.USRX0
     , SDD_PVL_rec15.USRX1
     , SDD_PVL_rec15.USRX2
     , SDD_PVL_rec15.USRX3
     , SDD_PVL_rec15.USRX4
     , SDD_PVL_rec15.USRX5
     , SDD_PVL_rec15.USRX6
     , SDD_PVL_rec15.USRX7
     , SDD_PVL_rec15.USRX8
     , SDD_PVL_rec15.USRX9
     , SDD_PVL_rec15.USRX10
     , SDD_PVL_rec15.USRX11
     , SDD_PVL_rec15.USRX12
     , SDD_PVL_rec15.USRX13
     , SDD_PVL_rec15.USRX14
     , SDD_PVL_rec15.USRX15
     , SDD_PVL_rec15.USRX16
     , SDD_PVL_rec15.USRX17
     , SDD_PVL_rec15.USRX18
     , SDD_PVL_rec15.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_PVL_rec15.irid, SDD_PVL_rec15.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_MODPGD_rec16 in SDD_MODPGD_cur16 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_MODPGD
    values (
       SDD_MODPGD_rec16.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_MODPGD_rec16.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_MODPGD_rec16.TYPES
     , SDD_MODPGD_rec16.ELEMENT_TYPE_NAME
     , SDD_MODPGD_rec16.DATE_CREATED
     , SDD_MODPGD_rec16.CREATED_BY
     , SDD_MODPGD_rec16.DATE_CHANGED
     , SDD_MODPGD_rec16.CHANGED_BY
     , SDD_MODPGD_rec16.NOTM
     , SDD_MODPGD_rec16.GENERAL_MODULE_REF
     , SDD_MODPGD_rec16.PLSQL_MODULE_REF
     , SDD_MODPGD_rec16.PROGRAM_DATUM_REF
     , SDD_MODPGD_rec16.SEQUENCE
     , SDD_MODPGD_rec16.READ
     , SDD_MODPGD_rec16.WRITEABLE
     , SDD_MODPGD_rec16.METHOD_OF_USE
     , SDD_MODPGD_rec16.MODULE_TYPE_FOR
     , SDD_MODPGD_rec16.USRX0
     , SDD_MODPGD_rec16.USRX1
     , SDD_MODPGD_rec16.USRX2
     , SDD_MODPGD_rec16.USRX3
     , SDD_MODPGD_rec16.USRX4
     , SDD_MODPGD_rec16.USRX5
     , SDD_MODPGD_rec16.USRX6
     , SDD_MODPGD_rec16.USRX7
     , SDD_MODPGD_rec16.USRX8
     , SDD_MODPGD_rec16.USRX9
     , SDD_MODPGD_rec16.USRX10
     , SDD_MODPGD_rec16.USRX11
     , SDD_MODPGD_rec16.USRX12
     , SDD_MODPGD_rec16.USRX13
     , SDD_MODPGD_rec16.USRX14
     , SDD_MODPGD_rec16.USRX15
     , SDD_MODPGD_rec16.USRX16
     , SDD_MODPGD_rec16.USRX17
     , SDD_MODPGD_rec16.USRX18
     , SDD_MODPGD_rec16.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_MODPGD_rec16.irid, SDD_MODPGD_rec16.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_MUN_rec17 in SDD_MUN_cur17 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_MUN
    values (
       SDD_MUN_rec17.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_MUN_rec17.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_MUN_rec17.TYPES
     , SDD_MUN_rec17.ELEMENT_TYPE_NAME
     , SDD_MUN_rec17.DATE_CREATED
     , SDD_MUN_rec17.CREATED_BY
     , SDD_MUN_rec17.DATE_CHANGED
     , SDD_MUN_rec17.CHANGED_BY
     , SDD_MUN_rec17.NOTM
     , SDD_MUN_rec17.GENERAL_MODULE_REF
     , SDD_MUN_rec17.MODULE_COMPONENT_REF
     , SDD_MUN_rec17.NAME
     , SDD_MUN_rec17.SHORT_DESCRIPTION
     , SDD_MUN_rec17.IMPLEMENTATION_ITEM
     , SDD_MUN_rec17.LANGUAGE_REF
     , SDD_MUN_rec17.MODULE_LEVEL_FLAG
     , SDD_MUN_rec17.DATASOURCE_TYPE
     , SDD_MUN_rec17.DATATARGET_TYPE
     , SDD_MUN_rec17.INSERT_FLAG
     , SDD_MUN_rec17.DELETE_FLAG
     , SDD_MUN_rec17.UPDATE_FLAG
     , SDD_MUN_rec17.SELECT_FLAG
     , SDD_MUN_rec17.AUTOQUERY_FLAG
     , SDD_MUN_rec17.DISPLAY_TITLE
     , SDD_MUN_rec17.LAYOUT_STYLE
     , SDD_MUN_rec17.ROWS_DISPLAYED
     , SDD_MUN_rec17.REQ_OVERFLOW
     , SDD_MUN_rec17.REQ_PAGE_WIDTH
     , SDD_MUN_rec17.REQ_PAGE_HEIGHT
     , SDD_MUN_rec17.REQ_VIEW_WIDTH
     , SDD_MUN_rec17.REQ_VIEW_HEIGHT
     , SDD_MUN_rec17.MODULE_UNIT_SUBTYPE
     , SDD_MUN_rec17.HELP_CONTEXT_ID_PREFIX
     , SDD_MUN_rec17.RUNTIME_PATHNAME
     , SDD_MUN_rec17.HELP_CONTEXT_ID_SUFFIX
     , SDD_MUN_rec17.USRX0
     , SDD_MUN_rec17.USRX1
     , SDD_MUN_rec17.USRX2
     , SDD_MUN_rec17.USRX3
     , SDD_MUN_rec17.USRX4
     , SDD_MUN_rec17.USRX5
     , SDD_MUN_rec17.USRX6
     , SDD_MUN_rec17.USRX7
     , SDD_MUN_rec17.USRX8
     , SDD_MUN_rec17.USRX9
     , SDD_MUN_rec17.USRX10
     , SDD_MUN_rec17.USRX11
     , SDD_MUN_rec17.USRX12
     , SDD_MUN_rec17.USRX13
     , SDD_MUN_rec17.USRX14
     , SDD_MUN_rec17.USRX15
     , SDD_MUN_rec17.USRX16
     , SDD_MUN_rec17.USRX17
     , SDD_MUN_rec17.USRX18
     , SDD_MUN_rec17.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_MUN_rec17.irid, SDD_MUN_rec17.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_IGR_rec18 in SDD_IGR_cur18 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_IGR
    values (
       SDD_IGR_rec18.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_IGR_rec18.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_IGR_rec18.TYPES
     , SDD_IGR_rec18.ELEMENT_TYPE_NAME
     , SDD_IGR_rec18.DATE_CREATED
     , SDD_IGR_rec18.CREATED_BY
     , SDD_IGR_rec18.DATE_CHANGED
     , SDD_IGR_rec18.CHANGED_BY
     , SDD_IGR_rec18.NOTM
     , SDD_IGR_rec18.MODULE_COMPONENT_REF
     , SDD_IGR_rec18.SUBCOMPONENT_REF
     , SDD_IGR_rec18.NAME
     , SDD_IGR_rec18.ITEM_GROUP_REF
     , SDD_IGR_rec18.PROMPT
     , SDD_IGR_rec18.IMPLEMENTATION_ITEM
     , SDD_IGR_rec18.STYLE
     , SDD_IGR_rec18.ORIENTATION
     , SDD_IGR_rec18.STACKED_FLAG
     , SDD_IGR_rec18.TAB_SCOPE
     , SDD_IGR_rec18.START_TAB
     , SDD_IGR_rec18.END_TAB
     , SDD_IGR_rec18.BREAK_GROUP_FLAG
     , SDD_IGR_rec18.BREAK_GROUP_STYLE
     , SDD_IGR_rec18.USRX0
     , SDD_IGR_rec18.USRX1
     , SDD_IGR_rec18.USRX2
     , SDD_IGR_rec18.USRX3
     , SDD_IGR_rec18.USRX4
     , SDD_IGR_rec18.USRX5
     , SDD_IGR_rec18.USRX6
     , SDD_IGR_rec18.USRX7
     , SDD_IGR_rec18.USRX8
     , SDD_IGR_rec18.USRX9
     , SDD_IGR_rec18.USRX10
     , SDD_IGR_rec18.USRX11
     , SDD_IGR_rec18.USRX12
     , SDD_IGR_rec18.USRX13
     , SDD_IGR_rec18.USRX14
     , SDD_IGR_rec18.USRX15
     , SDD_IGR_rec18.USRX16
     , SDD_IGR_rec18.USRX17
     , SDD_IGR_rec18.USRX18
     , SDD_IGR_rec18.USRX19
     , SDD_IGR_rec18.ITEM_GROUP_FOR
    );
  jr_reg_ver.vercopy_dependencies(SDD_IGR_rec18.irid, SDD_IGR_rec18.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_ITE_rec19 in SDD_ITE_cur19 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ITE
    values (
       SDD_ITE_rec19.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ITE_rec19.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ITE_rec19.TYPES
     , SDD_ITE_rec19.ELEMENT_TYPE_NAME
     , SDD_ITE_rec19.DATE_CREATED
     , SDD_ITE_rec19.CREATED_BY
     , SDD_ITE_rec19.DATE_CHANGED
     , SDD_ITE_rec19.CHANGED_BY
     , SDD_ITE_rec19.NOTM
     , SDD_ITE_rec19.MODULE_UNIT_REF
     , SDD_ITE_rec19.SQL_QUERY_SET_REF
     , SDD_ITE_rec19.DETAIL_TABLE_USAGE_REF
     , SDD_ITE_rec19.COLUMN_REF
     , SDD_ITE_rec19.NAME
     , SDD_ITE_rec19.UNBOUND_TYPE
     , SDD_ITE_rec19.USAGE_SEQUENCE
     , SDD_ITE_rec19.INSERT_FLAG
     , SDD_ITE_rec19.UPDATE_FLAG
     , SDD_ITE_rec19.SELECT_FLAG
     , SDD_ITE_rec19.RANGE_SEARCH_FLAG
     , SDD_ITE_rec19.CONTEXT_OPTION_QUERY_FLAG
     , SDD_ITE_rec19.DISPLAY_FLAG
     , SDD_ITE_rec19.IMPLEMENTATION_ITEM
     , SDD_ITE_rec19.PROMPT
     , SDD_ITE_rec19.DISPLAY_TYPE
     , SDD_ITE_rec19.SHOW_MEANING
     , SDD_ITE_rec19.DISPLAY_WIDTH
     , SDD_ITE_rec19.DISPLAY_HEIGHT
     , SDD_ITE_rec19.JUSTIFICATION
     , SDD_ITE_rec19.DISPLAY_FORMAT
     , SDD_ITE_rec19.HIGHLIGHTING
     , SDD_ITE_rec19.TRUNCATE_FLAG
     , SDD_ITE_rec19.ITEM_GROUP_REF
     , SDD_ITE_rec19.CONTEXT_FLAG
     , SDD_ITE_rec19.START_TAB
     , SDD_ITE_rec19.END_TAB
     , SDD_ITE_rec19.ALIGN_PROMPT_FLAG
     , SDD_ITE_rec19.DOMAIN_REF
     , SDD_ITE_rec19.DATATYPE
     , SDD_ITE_rec19.DEFAULT_VALUE
     , SDD_ITE_rec19.NULLIFY_FLAG
     , SDD_ITE_rec19.ORDER_SEQUENCE
     , SDD_ITE_rec19.SORTING_ORDER
     , SDD_ITE_rec19.RESET_LEVEL
     , SDD_ITE_rec19.RESET_GROUP
     , SDD_ITE_rec19.SOFT_LOV
     , SDD_ITE_rec19.HINT_TEXT
     , SDD_ITE_rec19.HELP_CONTEXT_ID_SUFFIX
     , SDD_ITE_rec19.ITEM_TYPE
     , SDD_ITE_rec19.REMARK
     , SDD_ITE_rec19.ITEM_FOR
     , SDD_ITE_rec19.DEFAULT_VALUE_TYPE
     , SDD_ITE_rec19.MAXIMUM_LENGTH
     , SDD_ITE_rec19.USRX0
     , SDD_ITE_rec19.USRX1
     , SDD_ITE_rec19.USRX2
     , SDD_ITE_rec19.USRX3
     , SDD_ITE_rec19.USRX4
     , SDD_ITE_rec19.USRX5
     , SDD_ITE_rec19.USRX6
     , SDD_ITE_rec19.USRX7
     , SDD_ITE_rec19.USRX8
     , SDD_ITE_rec19.USRX9
     , SDD_ITE_rec19.USRX10
     , SDD_ITE_rec19.USRX11
     , SDD_ITE_rec19.USRX12
     , SDD_ITE_rec19.USRX13
     , SDD_ITE_rec19.USRX14
     , SDD_ITE_rec19.USRX15
     , SDD_ITE_rec19.USRX16
     , SDD_ITE_rec19.USRX17
     , SDD_ITE_rec19.USRX18
     , SDD_ITE_rec19.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ITE_rec19.irid, SDD_ITE_rec19.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_MTI_rec20 in SDD_MTI_cur20 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_MTI
    values (
       SDD_MTI_rec20.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_MTI_rec20.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_MTI_rec20.TYPES
     , SDD_MTI_rec20.ELEMENT_TYPE_NAME
     , SDD_MTI_rec20.DATE_CREATED
     , SDD_MTI_rec20.CREATED_BY
     , SDD_MTI_rec20.DATE_CHANGED
     , SDD_MTI_rec20.CHANGED_BY
     , SDD_MTI_rec20.NOTM
     , SDD_MTI_rec20.MODULE_UNIT_REF
     , SDD_MTI_rec20.SQL_QUERY_SET_REF
     , SDD_MTI_rec20.TABLE_REF
     , SDD_MTI_rec20.ALIAS
     , SDD_MTI_rec20.NAME_IN_DATABASE
     , SDD_MTI_rec20.PARTITION_NAME
     , SDD_MTI_rec20.USAGE_TYPE
     , SDD_MTI_rec20.SELECT_DISTINCT_FLAG
     , SDD_MTI_rec20.MTI_REF
     , SDD_MTI_rec20.CONSTRAINT_REF
     , SDD_MTI_rec20.OUTER_JOIN_FLAG
     , SDD_MTI_rec20.NOT_EXISTS_FLAG
     , SDD_MTI_rec20.TREEWALK_JOIN_CONSTRAINT
     , SDD_MTI_rec20.CONSTRAINT_REF2
     , SDD_MTI_rec20.TREEWALK_DIRECTION
     , SDD_MTI_rec20.REMARK
     , SDD_MTI_rec20.REPORT_USAGE_TYPE
     , SDD_MTI_rec20.MTI_FOR
     , SDD_MTI_rec20.USRX0
     , SDD_MTI_rec20.USRX1
     , SDD_MTI_rec20.USRX2
     , SDD_MTI_rec20.USRX3
     , SDD_MTI_rec20.USRX4
     , SDD_MTI_rec20.USRX5
     , SDD_MTI_rec20.USRX6
     , SDD_MTI_rec20.USRX7
     , SDD_MTI_rec20.USRX8
     , SDD_MTI_rec20.USRX9
     , SDD_MTI_rec20.USRX10
     , SDD_MTI_rec20.USRX11
     , SDD_MTI_rec20.USRX12
     , SDD_MTI_rec20.USRX13
     , SDD_MTI_rec20.USRX14
     , SDD_MTI_rec20.USRX15
     , SDD_MTI_rec20.USRX16
     , SDD_MTI_rec20.USRX17
     , SDD_MTI_rec20.USRX18
     , SDD_MTI_rec20.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_MTI_rec20.irid, SDD_MTI_rec20.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_CNU_rec21 in SDD_CNU_cur21 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_CNU
    values (
       SDD_CNU_rec21.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_CNU_rec21.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_CNU_rec21.TYPES
     , SDD_CNU_rec21.ELEMENT_TYPE_NAME
     , SDD_CNU_rec21.DATE_CREATED
     , SDD_CNU_rec21.CREATED_BY
     , SDD_CNU_rec21.DATE_CHANGED
     , SDD_CNU_rec21.CHANGED_BY
     , SDD_CNU_rec21.NOTM
     , SDD_CNU_rec21.CONSTRAINT_REF
     , SDD_CNU_rec21.TABLE_USAGE_REF
    );
  jr_reg_ver.vercopy_dependencies(SDD_CNU_rec21.irid, SDD_CNU_rec21.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_SQS_rec22 in SDD_SQS_cur22 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_SQS
    values (
       SDD_SQS_rec22.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_SQS_rec22.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_SQS_rec22.TYPES
     , SDD_SQS_rec22.ELEMENT_TYPE_NAME
     , SDD_SQS_rec22.DATE_CREATED
     , SDD_SQS_rec22.CREATED_BY
     , SDD_SQS_rec22.DATE_CHANGED
     , SDD_SQS_rec22.CHANGED_BY
     , SDD_SQS_rec22.NOTM
     , SDD_SQS_rec22.MODULE_COMPONENT_REF
     , SDD_SQS_rec22.LIST_OF_VALUES_REF
     , SDD_SQS_rec22.NAME
     , SDD_SQS_rec22.SEQUENCE_NUMBER
     , SDD_SQS_rec22.USRX0
     , SDD_SQS_rec22.USRX1
     , SDD_SQS_rec22.USRX2
     , SDD_SQS_rec22.USRX3
     , SDD_SQS_rec22.USRX4
     , SDD_SQS_rec22.USRX5
     , SDD_SQS_rec22.USRX6
     , SDD_SQS_rec22.USRX7
     , SDD_SQS_rec22.USRX8
     , SDD_SQS_rec22.USRX9
     , SDD_SQS_rec22.USRX10
     , SDD_SQS_rec22.USRX11
     , SDD_SQS_rec22.USRX12
     , SDD_SQS_rec22.USRX13
     , SDD_SQS_rec22.USRX14
     , SDD_SQS_rec22.USRX15
     , SDD_SQS_rec22.USRX16
     , SDD_SQS_rec22.USRX17
     , SDD_SQS_rec22.USRX18
     , SDD_SQS_rec22.USRX19
     , SDD_SQS_rec22.SQL_QUERY_SET_FOR
    );
  jr_reg_ver.vercopy_dependencies(SDD_SQS_rec22.irid, SDD_SQS_rec22.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_PGD_rec23 in SDD_PGD_cur23 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_PGD
    values (
       SDD_PGD_rec23.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_PGD_rec23.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_PGD_rec23.TYPES
     , SDD_PGD_rec23.ELEMENT_TYPE_NAME
     , SDD_PGD_rec23.DATE_CREATED
     , SDD_PGD_rec23.CREATED_BY
     , SDD_PGD_rec23.DATE_CHANGED
     , SDD_PGD_rec23.CHANGED_BY
     , SDD_PGD_rec23.NOTM
     , SDD_PGD_rec23.PLSQL_MODULE_REF
     , SDD_PGD_rec23.GENERAL_MODULE_REF
     , SDD_PGD_rec23.NAME
     , SDD_PGD_rec23.DATA_CONSTRUCT_TYPE
     , SDD_PGD_rec23.SCOPE
     , SDD_PGD_rec23.SEQUENCE
     , SDD_PGD_rec23.DOMAIN_REF
     , SDD_PGD_rec23.DATASTRUCTURE_REF
     , SDD_PGD_rec23.COLUMN_REF
     , SDD_PGD_rec23.TABLE_DEFINITION_REF
     , SDD_PGD_rec23.ORACLE_TYPE_REF
     , SDD_PGD_rec23.VALUE_DATATYPE
     , SDD_PGD_rec23.VALUE_LENGTH
     , SDD_PGD_rec23.VALUE_SCALE
     , SDD_PGD_rec23.VALUE_DEFAULT
     , SDD_PGD_rec23.VALUE_DEFAULT_TYPE
     , SDD_PGD_rec23.OPTIONAL_FLAG
     , SDD_PGD_rec23.DELIMITER
     , SDD_PGD_rec23.ORACLE_ERROR_CODE_NUMBER
     , SDD_PGD_rec23.REMARK
     , SDD_PGD_rec23.DESCRIPTION
     , SDD_PGD_rec23.PROGRAM_DATUM_FOR
     , SDD_PGD_rec23.MODULE_TYPE_FOR
     , SDD_PGD_rec23.USRX0
     , SDD_PGD_rec23.USRX1
     , SDD_PGD_rec23.USRX2
     , SDD_PGD_rec23.USRX3
     , SDD_PGD_rec23.USRX4
     , SDD_PGD_rec23.USRX5
     , SDD_PGD_rec23.USRX6
     , SDD_PGD_rec23.USRX7
     , SDD_PGD_rec23.USRX8
     , SDD_PGD_rec23.USRX9
     , SDD_PGD_rec23.USRX10
     , SDD_PGD_rec23.USRX11
     , SDD_PGD_rec23.USRX12
     , SDD_PGD_rec23.USRX13
     , SDD_PGD_rec23.USRX14
     , SDD_PGD_rec23.USRX15
     , SDD_PGD_rec23.USRX16
     , SDD_PGD_rec23.USRX17
     , SDD_PGD_rec23.USRX18
     , SDD_PGD_rec23.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_PGD_rec23.irid, SDD_PGD_rec23.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_WIN_rec24 in SDD_WIN_cur24 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_WIN
    values (
       SDD_WIN_rec24.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_WIN_rec24.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_WIN_rec24.TYPES
     , SDD_WIN_rec24.ELEMENT_TYPE_NAME
     , SDD_WIN_rec24.DATE_CREATED
     , SDD_WIN_rec24.CREATED_BY
     , SDD_WIN_rec24.DATE_CHANGED
     , SDD_WIN_rec24.CHANGED_BY
     , SDD_WIN_rec24.NOTM
     , SDD_WIN_rec24.GENERAL_MODULE_REF
     , SDD_WIN_rec24.NAME
     , SDD_WIN_rec24.TITLE
     , SDD_WIN_rec24.IMPLEMENTATION_ITEM
     , SDD_WIN_rec24.SCROLLABLE_FLAG
     , SDD_WIN_rec24.REQ_WIDTH
     , SDD_WIN_rec24.REQ_HEIGHT
     , SDD_WIN_rec24.REQ_POSX
     , SDD_WIN_rec24.REQ_POSY
     , SDD_WIN_rec24.USRX0
     , SDD_WIN_rec24.USRX1
     , SDD_WIN_rec24.USRX2
     , SDD_WIN_rec24.USRX3
     , SDD_WIN_rec24.USRX4
     , SDD_WIN_rec24.USRX5
     , SDD_WIN_rec24.USRX6
     , SDD_WIN_rec24.USRX7
     , SDD_WIN_rec24.USRX8
     , SDD_WIN_rec24.USRX9
     , SDD_WIN_rec24.USRX10
     , SDD_WIN_rec24.USRX11
     , SDD_WIN_rec24.USRX12
     , SDD_WIN_rec24.USRX13
     , SDD_WIN_rec24.USRX14
     , SDD_WIN_rec24.USRX15
     , SDD_WIN_rec24.USRX16
     , SDD_WIN_rec24.USRX17
     , SDD_WIN_rec24.USRX18
     , SDD_WIN_rec24.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_WIN_rec24.irid, SDD_WIN_rec24.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  jr_reg_ver.vercopy_dependent_objects(SDD_MOD_ver.ivid, new_ivid);
  return new_ivid;
end SDD_MOD_ver;
/
create or replace function PK_SDD_MOD (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_MOD the_tab_new, SDD_MOD the_tab_old
  where  the_tab_new.ivid = PK_SDD_MOD.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_MOD.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_MOD;
/
create or replace function FK_MOD_TO_JAM (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.JAVA_MODULE_REF ref_value
  from   i$SDD_MOD the_tab
  where  the_tab.ivid = FK_MOD_TO_JAM.object_ivid
  and    the_tab.JAVA_MODULE_REF is not null
  and    not exists (
             select null
             from   SDD_MOD foreign_tab
             where  the_tab.JAVA_MODULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5022, action);
  end loop;
  return is_ok;
end FK_MOD_TO_JAM;
/
create or replace function FK_MOD_TO_LAN (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.LANGUAGE_REF ref_value
  from   i$SDD_MOD the_tab
  where  the_tab.ivid = FK_MOD_TO_LAN.object_ivid
  and    the_tab.LANGUAGE_REF is not null
  and    not exists (
             select null
             from   SDD_LAN foreign_tab
             where  the_tab.LANGUAGE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4996, action);
  end loop;
  return is_ok;
end FK_MOD_TO_LAN;
/
create or replace function FK_MOD_TO_ORT (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ORACLE_TYPE_REF ref_value
  from   i$SDD_MOD the_tab
  where  the_tab.ivid = FK_MOD_TO_ORT.object_ivid
  and    the_tab.ORACLE_TYPE_REF is not null
  and    not exists (
             select null
             from   SDD_ORT foreign_tab
             where  the_tab.ORACLE_TYPE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4858, action);
  end loop;
  return is_ok;
end FK_MOD_TO_ORT;
/
create or replace function PK_SDD_MODBUN (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_MODBUN the_tab_new, SDD_MODBUN the_tab_old
  where  the_tab_new.ivid = PK_SDD_MODBUN.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_MODBUN.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_MODBUN;
/
create or replace function FK_MODBUN_TO_BUN (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.BUSINESS_UNIT_REF ref_value
  from   i$SDD_MODBUN the_tab
  where  the_tab.ivid = FK_MODBUN_TO_BUN.object_ivid
  and    the_tab.BUSINESS_UNIT_REF is not null
  and    not exists (
             select null
             from   SDD_BUN foreign_tab
             where  the_tab.BUSINESS_UNIT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5005, action);
  end loop;
  return is_ok;
end FK_MODBUN_TO_BUN;
/
create or replace function FK_MODBUN_TO_MOD (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.MODULE_REF ref_value
  from   i$SDD_MODBUN the_tab
  where  the_tab.ivid = FK_MODBUN_TO_MOD.object_ivid
  and    the_tab.MODULE_REF is not null
  and    not exists (
             select null
             from   SDD_MOD foreign_tab
             where  the_tab.MODULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5022, action);
  end loop;
  return is_ok;
end FK_MODBUN_TO_MOD;
/
create or replace function PK_SDD_MODFUN (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_MODFUN the_tab_new, SDD_MODFUN the_tab_old
  where  the_tab_new.ivid = PK_SDD_MODFUN.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_MODFUN.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_MODFUN;
/
create or replace function FK_MODFUN_TO_FUN (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.FUNCTION_REF ref_value
  from   i$SDD_MODFUN the_tab
  where  the_tab.ivid = FK_MODFUN_TO_FUN.object_ivid
  and    the_tab.FUNCTION_REF is not null
  and    not exists (
             select null
             from   SDD_FUN foreign_tab
             where  the_tab.FUNCTION_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5024, action);
  end loop;
  return is_ok;
end FK_MODFUN_TO_FUN;
/
create or replace function FK_MODFUN_TO_MOD (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.MODULE_REF ref_value
  from   i$SDD_MODFUN the_tab
  where  the_tab.ivid = FK_MODFUN_TO_MOD.object_ivid
  and    the_tab.MODULE_REF is not null
  and    not exists (
             select null
             from   SDD_MOD foreign_tab
             where  the_tab.MODULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5022, action);
  end loop;
  return is_ok;
end FK_MODFUN_TO_MOD;
/
create or replace function PK_SDD_MODMOD (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_MODMOD the_tab_new, SDD_MODMOD the_tab_old
  where  the_tab_new.ivid = PK_SDD_MODMOD.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_MODMOD.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_MODMOD;
/
create or replace function FK_MODMOD_TO_MOD (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.PARENT_MODULE_REF ref_value
  from   i$SDD_MODMOD the_tab
  where  the_tab.ivid = FK_MODMOD_TO_MOD.object_ivid
  and    the_tab.PARENT_MODULE_REF is not null
  and    not exists (
             select null
             from   SDD_MOD foreign_tab
             where  the_tab.PARENT_MODULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5022, action);
  end loop;
  return is_ok;
end FK_MODMOD_TO_MOD;
/
create or replace function FK_MODMOD_TO_MOD2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.CHILD_MODULE_REF ref_value
  from   i$SDD_MODMOD the_tab
  where  the_tab.ivid = FK_MODMOD_TO_MOD2.object_ivid
  and    the_tab.CHILD_MODULE_REF is not null
  and    not exists (
             select null
             from   SDD_MOD foreign_tab
             where  the_tab.CHILD_MODULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5022, action);
  end loop;
  return is_ok;
end FK_MODMOD_TO_MOD2;
/
create or replace function PK_SDD_MODPGD (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_MODPGD the_tab_new, SDD_MODPGD the_tab_old
  where  the_tab_new.ivid = PK_SDD_MODPGD.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_MODPGD.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_MODPGD;
/
create or replace function FK_MODPGD_TO_GEM (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.GENERAL_MODULE_REF ref_value
  from   i$SDD_MODPGD the_tab
  where  the_tab.ivid = FK_MODPGD_TO_GEM.object_ivid
  and    the_tab.GENERAL_MODULE_REF is not null
  and    not exists (
             select null
             from   SDD_MOD foreign_tab
             where  the_tab.GENERAL_MODULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5022, action);
  end loop;
  return is_ok;
end FK_MODPGD_TO_GEM;
/
create or replace function FK_MODPGD_TO_PGD (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.PROGRAM_DATUM_REF ref_value
  from   i$SDD_MODPGD the_tab
  where  the_tab.ivid = FK_MODPGD_TO_PGD.object_ivid
  and    the_tab.PROGRAM_DATUM_REF is not null
  and    not exists (
             select null
             from   SDD_PGD foreign_tab
             where  the_tab.PROGRAM_DATUM_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4984, action);
  end loop;
  return is_ok;
end FK_MODPGD_TO_PGD;
/
create or replace function FK_MODPGD_TO_PLM (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.PLSQL_MODULE_REF ref_value
  from   i$SDD_MODPGD the_tab
  where  the_tab.ivid = FK_MODPGD_TO_PLM.object_ivid
  and    the_tab.PLSQL_MODULE_REF is not null
  and    not exists (
             select null
             from   SDD_MOD foreign_tab
             where  the_tab.PLSQL_MODULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5022, action);
  end loop;
  return is_ok;
end FK_MODPGD_TO_PLM;
/
create or replace function FK_CMA_TO_MPA_cmd (irid number, ivid number) return boolean as
cursor bad_cur is
  select child_tab.irid child_irid, child_tab.types child_type
        ,parent_tab.ivid par_ivid, parent_tab.types par_type
  from   SDD_CMA child_tab, i$SDD_MPA parent_tab
  where  parent_tab.parent_ivid=FK_CMA_TO_MPA_cmd.ivid
  and    child_tab.METHOD_PARAMETER_REF=parent_tab.IRID
  ;
  is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
   insert into I$SDD_INVALID_OBJECTS(object_irid,object_ivid,table_irid)
    select o.irid,o.ivid,o.table_irid
      from SDD_CMA child_tab
          ,i$SDD_MPA parent_tab
          ,I$SDD_OBJECT_VERSIONS o
     where parent_tab.parent_ivid=FK_CMA_TO_MPA_cmd.ivid
       and child_tab.METHOD_PARAMETER_REF=parent_tab.IRID
       and child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(ref.par_ivid,ref.par_type,ref.child_irid,ref.child_type,'DEL');
  end loop;
  return is_ok;
end FK_CMA_TO_MPA_cmd;
/
create or replace function FK_CMA_TO_MPA_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_CMA child_tab
  where  child_tab.METHOD_PARAMETER_REF=FK_CMA_TO_MPA_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_CMA child_tab, i$sdd_object_versions o
    where  child_tab.METHOD_PARAMETER_REF=FK_CMA_TO_MPA_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_CMA_TO_MPA_d;
/
create or replace function PK_SDD_MPA (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_MPA the_tab_new, SDD_MPA the_tab_old
  where  the_tab_new.ivid = PK_SDD_MPA.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_MPA.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_MPA;
/
create or replace function FK_MPA_TO_CLA (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.CLASSIFIER_REF ref_value
  from   i$SDD_MPA the_tab
  where  the_tab.ivid = FK_MPA_TO_CLA.object_ivid
  and    the_tab.CLASSIFIER_REF is not null
  and    not exists (
             select null
             from   SDD_CLA foreign_tab
             where  the_tab.CLASSIFIER_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4841, action);
  end loop;
  return is_ok;
end FK_MPA_TO_CLA;
/
create or replace function FK_MPA_TO_CLA2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.COLLECT_CLASSIFIER_REF ref_value
  from   i$SDD_MPA the_tab
  where  the_tab.ivid = FK_MPA_TO_CLA2.object_ivid
  and    the_tab.COLLECT_CLASSIFIER_REF is not null
  and    not exists (
             select null
             from   SDD_CLA foreign_tab
             where  the_tab.COLLECT_CLASSIFIER_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4841, action);
  end loop;
  return is_ok;
end FK_MPA_TO_CLA2;
/
create or replace function FK_MTI_TO_MTI_cmd (irid number, ivid number) return boolean as
cursor bad_cur is
  select child_tab.irid child_irid, child_tab.types child_type
        ,parent_tab.ivid par_ivid, parent_tab.types par_type
  from   SDD_MTI child_tab, i$SDD_MTI parent_tab
  where  parent_tab.parent_ivid=FK_MTI_TO_MTI_cmd.ivid
  and    child_tab.MTI_REF=parent_tab.IRID
  ;
  is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
   insert into I$SDD_INVALID_OBJECTS(object_irid,object_ivid,table_irid)
    select o.irid,o.ivid,o.table_irid
      from SDD_MTI child_tab
          ,i$SDD_MTI parent_tab
          ,I$SDD_OBJECT_VERSIONS o
     where parent_tab.parent_ivid=FK_MTI_TO_MTI_cmd.ivid
       and child_tab.MTI_REF=parent_tab.IRID
       and child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(ref.par_ivid,ref.par_type,ref.child_irid,ref.child_type,'DEL');
  end loop;
  return is_ok;
end FK_MTI_TO_MTI_cmd;
/
create or replace function FK_MTI_TO_MTI_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_MTI child_tab
  where  child_tab.MTI_REF=FK_MTI_TO_MTI_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_MTI child_tab, i$sdd_object_versions o
    where  child_tab.MTI_REF=FK_MTI_TO_MTI_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_MTI_TO_MTI_d;
/
create or replace function PK_SDD_MTI (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_MTI the_tab_new, SDD_MTI the_tab_old
  where  the_tab_new.ivid = PK_SDD_MTI.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_MTI.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_MTI;
/
create or replace function FK_MTI_TO_JCO (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.CONSTRAINT_REF ref_value
  from   i$SDD_MTI the_tab
  where  the_tab.ivid = FK_MTI_TO_JCO.object_ivid
  and    the_tab.CONSTRAINT_REF is not null
  and    not exists (
             select null
             from   SDD_OCO foreign_tab
             where  the_tab.CONSTRAINT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5027, action);
  end loop;
  return is_ok;
end FK_MTI_TO_JCO;
/
create or replace function FK_MTI_TO_JCO2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.CONSTRAINT_REF2 ref_value
  from   i$SDD_MTI the_tab
  where  the_tab.ivid = FK_MTI_TO_JCO2.object_ivid
  and    the_tab.CONSTRAINT_REF2 is not null
  and    not exists (
             select null
             from   SDD_OCO foreign_tab
             where  the_tab.CONSTRAINT_REF2 = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5027, action);
  end loop;
  return is_ok;
end FK_MTI_TO_JCO2;
/
create or replace function FK_MTI_TO_JCO3 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.TREEWALK_JOIN_CONSTRAINT ref_value
  from   i$SDD_MTI the_tab
  where  the_tab.ivid = FK_MTI_TO_JCO3.object_ivid
  and    the_tab.TREEWALK_JOIN_CONSTRAINT is not null
  and    not exists (
             select null
             from   SDD_OCO foreign_tab
             where  the_tab.TREEWALK_JOIN_CONSTRAINT = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5027, action);
  end loop;
  return is_ok;
end FK_MTI_TO_JCO3;
/
create or replace function FK_MTI_TO_MTI (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.MTI_REF ref_value
  from   i$SDD_MTI the_tab
  where  the_tab.ivid = FK_MTI_TO_MTI.object_ivid
  and    the_tab.MTI_REF is not null
  and    not exists (
             select null
             from   SDD_MTI foreign_tab
             where  the_tab.MTI_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4998, action);
  end loop;
  return is_ok;
end FK_MTI_TO_MTI;
/
create or replace function FK_MTI_TO_MUN (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.MODULE_UNIT_REF ref_value
  from   i$SDD_MTI the_tab
  where  the_tab.ivid = FK_MTI_TO_MUN.object_ivid
  and    the_tab.MODULE_UNIT_REF is not null
  and    not exists (
             select null
             from   SDD_MUN foreign_tab
             where  the_tab.MODULE_UNIT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5051, action);
  end loop;
  return is_ok;
end FK_MTI_TO_MUN;
/
create or replace function FK_MTI_TO_TAB (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.TABLE_REF ref_value
  from   i$SDD_MTI the_tab
  where  the_tab.ivid = FK_MTI_TO_TAB.object_ivid
  and    the_tab.TABLE_REF is not null
  and    not exists (
             select null
             from   SDD_TAB foreign_tab
             where  the_tab.TABLE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4982, action);
  end loop;
  return is_ok;
end FK_MTI_TO_TAB;
/
create or replace function FK_MCN_TO_SUB_cmd (irid number, ivid number) return boolean as
cursor bad_cur is
  select child_tab.irid child_irid, child_tab.types child_type
        ,parent_tab.ivid par_ivid, parent_tab.types par_type
  from   SDD_MCN child_tab, i$SDD_MUN parent_tab
  where  parent_tab.parent_ivid=FK_MCN_TO_SUB_cmd.ivid
  and    child_tab.SUBCOMPONENT_REF=parent_tab.IRID
  ;
  is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
   insert into I$SDD_INVALID_OBJECTS(object_irid,object_ivid,table_irid)
    select o.irid,o.ivid,o.table_irid
      from SDD_MCN child_tab
          ,i$SDD_MUN parent_tab
          ,I$SDD_OBJECT_VERSIONS o
     where parent_tab.parent_ivid=FK_MCN_TO_SUB_cmd.ivid
       and child_tab.SUBCOMPONENT_REF=parent_tab.IRID
       and child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(ref.par_ivid,ref.par_type,ref.child_irid,ref.child_type,'DEL');
  end loop;
  return is_ok;
end FK_MCN_TO_SUB_cmd;
/
create or replace function FK_MCN_TO_SUB_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_MCN child_tab
  where  child_tab.SUBCOMPONENT_REF=FK_MCN_TO_SUB_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_MCN child_tab, i$sdd_object_versions o
    where  child_tab.SUBCOMPONENT_REF=FK_MCN_TO_SUB_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_MCN_TO_SUB_d;
/
create or replace function SDD_MUN_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_MUN_cur is
    select *
    from   i$SDD_MUN the_tab
    where  the_tab.irid=SDD_MUN_ver.irid
    and    the_tab.ivid=SDD_MUN_ver.ivid;
  SDD_MUN_rec SDD_MUN_cur%ROWTYPE;
  cursor SDD_IGR_cur1 is
    select *
    from i$SDD_IGR the_tab
    where the_tab.parent_ivid=SDD_MUN_ver.ivid;
  cursor SDD_ITE_cur2 is
    select *
    from i$SDD_ITE the_tab
    where the_tab.parent_ivid=SDD_MUN_ver.ivid;
  cursor SDD_ATV_cur3 is
    select *
    from i$SDD_ATV the_tab
    where the_tab.parent_ivid=SDD_MUN_ver.ivid;
  cursor SDD_MTI_cur4 is
    select *
    from i$SDD_MTI the_tab
    where the_tab.parent_ivid=SDD_MUN_ver.ivid;
  cursor SDD_CNU_cur5 is
    select *
    from i$SDD_CNU the_tab
    where the_tab.parent_ivid=SDD_MUN_ver.ivid;
  cursor SDD_MUN_cur6 is
    select *
    from i$SDD_MUN the_tab
    where the_tab.parent_ivid=SDD_MUN_ver.ivid;
  cursor SDD_SQS_cur7 is
    select *
    from i$SDD_SQS the_tab
    where the_tab.parent_ivid=SDD_MUN_ver.ivid;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_MUN_cur;
  fetch SDD_MUN_cur into SDD_MUN_rec;
  close SDD_MUN_cur;
  insert into i$SDD_MUN
  values (
    SDD_MUN_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_MUN_rec.pac_ref     -- pac_ref
   ,SDD_MUN_rec.parent_ivid -- parent_ivid
   ,SDD_MUN_rec.TYPES
   ,SDD_MUN_rec.ELEMENT_TYPE_NAME
   ,SDD_MUN_rec.DATE_CREATED
   ,SDD_MUN_rec.CREATED_BY
   ,SDD_MUN_rec.DATE_CHANGED
   ,SDD_MUN_rec.CHANGED_BY
   ,SDD_MUN_rec.NOTM
   ,SDD_MUN_rec.GENERAL_MODULE_REF
   ,SDD_MUN_rec.MODULE_COMPONENT_REF
   ,SDD_MUN_rec.NAME
   ,SDD_MUN_rec.SHORT_DESCRIPTION
   ,SDD_MUN_rec.IMPLEMENTATION_ITEM
   ,SDD_MUN_rec.LANGUAGE_REF
   ,SDD_MUN_rec.MODULE_LEVEL_FLAG
   ,SDD_MUN_rec.DATASOURCE_TYPE
   ,SDD_MUN_rec.DATATARGET_TYPE
   ,SDD_MUN_rec.INSERT_FLAG
   ,SDD_MUN_rec.DELETE_FLAG
   ,SDD_MUN_rec.UPDATE_FLAG
   ,SDD_MUN_rec.SELECT_FLAG
   ,SDD_MUN_rec.AUTOQUERY_FLAG
   ,SDD_MUN_rec.DISPLAY_TITLE
   ,SDD_MUN_rec.LAYOUT_STYLE
   ,SDD_MUN_rec.ROWS_DISPLAYED
   ,SDD_MUN_rec.REQ_OVERFLOW
   ,SDD_MUN_rec.REQ_PAGE_WIDTH
   ,SDD_MUN_rec.REQ_PAGE_HEIGHT
   ,SDD_MUN_rec.REQ_VIEW_WIDTH
   ,SDD_MUN_rec.REQ_VIEW_HEIGHT
   ,SDD_MUN_rec.MODULE_UNIT_SUBTYPE
   ,SDD_MUN_rec.HELP_CONTEXT_ID_PREFIX
   ,SDD_MUN_rec.RUNTIME_PATHNAME
   ,SDD_MUN_rec.HELP_CONTEXT_ID_SUFFIX
   ,SDD_MUN_rec.USRX0
   ,SDD_MUN_rec.USRX1
   ,SDD_MUN_rec.USRX2
   ,SDD_MUN_rec.USRX3
   ,SDD_MUN_rec.USRX4
   ,SDD_MUN_rec.USRX5
   ,SDD_MUN_rec.USRX6
   ,SDD_MUN_rec.USRX7
   ,SDD_MUN_rec.USRX8
   ,SDD_MUN_rec.USRX9
   ,SDD_MUN_rec.USRX10
   ,SDD_MUN_rec.USRX11
   ,SDD_MUN_rec.USRX12
   ,SDD_MUN_rec.USRX13
   ,SDD_MUN_rec.USRX14
   ,SDD_MUN_rec.USRX15
   ,SDD_MUN_rec.USRX16
   ,SDD_MUN_rec.USRX17
   ,SDD_MUN_rec.USRX18
   ,SDD_MUN_rec.USRX19
  );
  jr_reg_ver.vercopy_dependencies(SDD_MUN_ver.irid, SDD_MUN_ver.ivid, new_ivid, null, copy_dependencies);
  for SDD_IGR_rec1 in SDD_IGR_cur1 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_IGR
    values (
       SDD_IGR_rec1.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_IGR_rec1.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_IGR_rec1.TYPES
     , SDD_IGR_rec1.ELEMENT_TYPE_NAME
     , SDD_IGR_rec1.DATE_CREATED
     , SDD_IGR_rec1.CREATED_BY
     , SDD_IGR_rec1.DATE_CHANGED
     , SDD_IGR_rec1.CHANGED_BY
     , SDD_IGR_rec1.NOTM
     , SDD_IGR_rec1.MODULE_COMPONENT_REF
     , SDD_IGR_rec1.SUBCOMPONENT_REF
     , SDD_IGR_rec1.NAME
     , SDD_IGR_rec1.ITEM_GROUP_REF
     , SDD_IGR_rec1.PROMPT
     , SDD_IGR_rec1.IMPLEMENTATION_ITEM
     , SDD_IGR_rec1.STYLE
     , SDD_IGR_rec1.ORIENTATION
     , SDD_IGR_rec1.STACKED_FLAG
     , SDD_IGR_rec1.TAB_SCOPE
     , SDD_IGR_rec1.START_TAB
     , SDD_IGR_rec1.END_TAB
     , SDD_IGR_rec1.BREAK_GROUP_FLAG
     , SDD_IGR_rec1.BREAK_GROUP_STYLE
     , SDD_IGR_rec1.USRX0
     , SDD_IGR_rec1.USRX1
     , SDD_IGR_rec1.USRX2
     , SDD_IGR_rec1.USRX3
     , SDD_IGR_rec1.USRX4
     , SDD_IGR_rec1.USRX5
     , SDD_IGR_rec1.USRX6
     , SDD_IGR_rec1.USRX7
     , SDD_IGR_rec1.USRX8
     , SDD_IGR_rec1.USRX9
     , SDD_IGR_rec1.USRX10
     , SDD_IGR_rec1.USRX11
     , SDD_IGR_rec1.USRX12
     , SDD_IGR_rec1.USRX13
     , SDD_IGR_rec1.USRX14
     , SDD_IGR_rec1.USRX15
     , SDD_IGR_rec1.USRX16
     , SDD_IGR_rec1.USRX17
     , SDD_IGR_rec1.USRX18
     , SDD_IGR_rec1.USRX19
     , SDD_IGR_rec1.ITEM_GROUP_FOR
    );
  jr_reg_ver.vercopy_dependencies(SDD_IGR_rec1.irid, SDD_IGR_rec1.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_ITE_rec2 in SDD_ITE_cur2 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ITE
    values (
       SDD_ITE_rec2.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ITE_rec2.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ITE_rec2.TYPES
     , SDD_ITE_rec2.ELEMENT_TYPE_NAME
     , SDD_ITE_rec2.DATE_CREATED
     , SDD_ITE_rec2.CREATED_BY
     , SDD_ITE_rec2.DATE_CHANGED
     , SDD_ITE_rec2.CHANGED_BY
     , SDD_ITE_rec2.NOTM
     , SDD_ITE_rec2.MODULE_UNIT_REF
     , SDD_ITE_rec2.SQL_QUERY_SET_REF
     , SDD_ITE_rec2.DETAIL_TABLE_USAGE_REF
     , SDD_ITE_rec2.COLUMN_REF
     , SDD_ITE_rec2.NAME
     , SDD_ITE_rec2.UNBOUND_TYPE
     , SDD_ITE_rec2.USAGE_SEQUENCE
     , SDD_ITE_rec2.INSERT_FLAG
     , SDD_ITE_rec2.UPDATE_FLAG
     , SDD_ITE_rec2.SELECT_FLAG
     , SDD_ITE_rec2.RANGE_SEARCH_FLAG
     , SDD_ITE_rec2.CONTEXT_OPTION_QUERY_FLAG
     , SDD_ITE_rec2.DISPLAY_FLAG
     , SDD_ITE_rec2.IMPLEMENTATION_ITEM
     , SDD_ITE_rec2.PROMPT
     , SDD_ITE_rec2.DISPLAY_TYPE
     , SDD_ITE_rec2.SHOW_MEANING
     , SDD_ITE_rec2.DISPLAY_WIDTH
     , SDD_ITE_rec2.DISPLAY_HEIGHT
     , SDD_ITE_rec2.JUSTIFICATION
     , SDD_ITE_rec2.DISPLAY_FORMAT
     , SDD_ITE_rec2.HIGHLIGHTING
     , SDD_ITE_rec2.TRUNCATE_FLAG
     , SDD_ITE_rec2.ITEM_GROUP_REF
     , SDD_ITE_rec2.CONTEXT_FLAG
     , SDD_ITE_rec2.START_TAB
     , SDD_ITE_rec2.END_TAB
     , SDD_ITE_rec2.ALIGN_PROMPT_FLAG
     , SDD_ITE_rec2.DOMAIN_REF
     , SDD_ITE_rec2.DATATYPE
     , SDD_ITE_rec2.DEFAULT_VALUE
     , SDD_ITE_rec2.NULLIFY_FLAG
     , SDD_ITE_rec2.ORDER_SEQUENCE
     , SDD_ITE_rec2.SORTING_ORDER
     , SDD_ITE_rec2.RESET_LEVEL
     , SDD_ITE_rec2.RESET_GROUP
     , SDD_ITE_rec2.SOFT_LOV
     , SDD_ITE_rec2.HINT_TEXT
     , SDD_ITE_rec2.HELP_CONTEXT_ID_SUFFIX
     , SDD_ITE_rec2.ITEM_TYPE
     , SDD_ITE_rec2.REMARK
     , SDD_ITE_rec2.ITEM_FOR
     , SDD_ITE_rec2.DEFAULT_VALUE_TYPE
     , SDD_ITE_rec2.MAXIMUM_LENGTH
     , SDD_ITE_rec2.USRX0
     , SDD_ITE_rec2.USRX1
     , SDD_ITE_rec2.USRX2
     , SDD_ITE_rec2.USRX3
     , SDD_ITE_rec2.USRX4
     , SDD_ITE_rec2.USRX5
     , SDD_ITE_rec2.USRX6
     , SDD_ITE_rec2.USRX7
     , SDD_ITE_rec2.USRX8
     , SDD_ITE_rec2.USRX9
     , SDD_ITE_rec2.USRX10
     , SDD_ITE_rec2.USRX11
     , SDD_ITE_rec2.USRX12
     , SDD_ITE_rec2.USRX13
     , SDD_ITE_rec2.USRX14
     , SDD_ITE_rec2.USRX15
     , SDD_ITE_rec2.USRX16
     , SDD_ITE_rec2.USRX17
     , SDD_ITE_rec2.USRX18
     , SDD_ITE_rec2.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ITE_rec2.irid, SDD_ITE_rec2.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_ATV_rec3 in SDD_ATV_cur3 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ATV
    values (
       SDD_ATV_rec3.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ATV_rec3.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ATV_rec3.TYPES
     , SDD_ATV_rec3.ELEMENT_TYPE_NAME
     , SDD_ATV_rec3.DATE_CREATED
     , SDD_ATV_rec3.CREATED_BY
     , SDD_ATV_rec3.DATE_CHANGED
     , SDD_ATV_rec3.CHANGED_BY
     , SDD_ATV_rec3.NOTM
     , SDD_ATV_rec3.ATTRIBUTE_REF
     , SDD_ATV_rec3.DOMAIN_REF
     , SDD_ATV_rec3.COLUMN_REF
     , SDD_ATV_rec3.MODULE_ARGUMENT_REF
     , SDD_ATV_rec3.UNBOUND_ITEM_REF
     , SDD_ATV_rec3.LOW_VALUE
     , SDD_ATV_rec3.HIGH_VALUE
     , SDD_ATV_rec3.ABBREVIATION
     , SDD_ATV_rec3.LOW_VALUE_TYPE
     , SDD_ATV_rec3.MEANING
     , SDD_ATV_rec3.HIGH_VALUE_TYPE
     , SDD_ATV_rec3.RADIO_SEQUENCE
     , SDD_ATV_rec3.ATTRIBUTE_VALUE_FOR
     , SDD_ATV_rec3.USRX0
     , SDD_ATV_rec3.USRX1
     , SDD_ATV_rec3.USRX2
     , SDD_ATV_rec3.USRX3
     , SDD_ATV_rec3.USRX4
     , SDD_ATV_rec3.USRX5
     , SDD_ATV_rec3.USRX6
     , SDD_ATV_rec3.USRX7
     , SDD_ATV_rec3.USRX8
     , SDD_ATV_rec3.USRX9
     , SDD_ATV_rec3.USRX10
     , SDD_ATV_rec3.USRX11
     , SDD_ATV_rec3.USRX12
     , SDD_ATV_rec3.USRX13
     , SDD_ATV_rec3.USRX14
     , SDD_ATV_rec3.USRX15
     , SDD_ATV_rec3.USRX16
     , SDD_ATV_rec3.USRX17
     , SDD_ATV_rec3.USRX18
     , SDD_ATV_rec3.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ATV_rec3.irid, SDD_ATV_rec3.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_MTI_rec4 in SDD_MTI_cur4 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_MTI
    values (
       SDD_MTI_rec4.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_MTI_rec4.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_MTI_rec4.TYPES
     , SDD_MTI_rec4.ELEMENT_TYPE_NAME
     , SDD_MTI_rec4.DATE_CREATED
     , SDD_MTI_rec4.CREATED_BY
     , SDD_MTI_rec4.DATE_CHANGED
     , SDD_MTI_rec4.CHANGED_BY
     , SDD_MTI_rec4.NOTM
     , SDD_MTI_rec4.MODULE_UNIT_REF
     , SDD_MTI_rec4.SQL_QUERY_SET_REF
     , SDD_MTI_rec4.TABLE_REF
     , SDD_MTI_rec4.ALIAS
     , SDD_MTI_rec4.NAME_IN_DATABASE
     , SDD_MTI_rec4.PARTITION_NAME
     , SDD_MTI_rec4.USAGE_TYPE
     , SDD_MTI_rec4.SELECT_DISTINCT_FLAG
     , SDD_MTI_rec4.MTI_REF
     , SDD_MTI_rec4.CONSTRAINT_REF
     , SDD_MTI_rec4.OUTER_JOIN_FLAG
     , SDD_MTI_rec4.NOT_EXISTS_FLAG
     , SDD_MTI_rec4.TREEWALK_JOIN_CONSTRAINT
     , SDD_MTI_rec4.CONSTRAINT_REF2
     , SDD_MTI_rec4.TREEWALK_DIRECTION
     , SDD_MTI_rec4.REMARK
     , SDD_MTI_rec4.REPORT_USAGE_TYPE
     , SDD_MTI_rec4.MTI_FOR
     , SDD_MTI_rec4.USRX0
     , SDD_MTI_rec4.USRX1
     , SDD_MTI_rec4.USRX2
     , SDD_MTI_rec4.USRX3
     , SDD_MTI_rec4.USRX4
     , SDD_MTI_rec4.USRX5
     , SDD_MTI_rec4.USRX6
     , SDD_MTI_rec4.USRX7
     , SDD_MTI_rec4.USRX8
     , SDD_MTI_rec4.USRX9
     , SDD_MTI_rec4.USRX10
     , SDD_MTI_rec4.USRX11
     , SDD_MTI_rec4.USRX12
     , SDD_MTI_rec4.USRX13
     , SDD_MTI_rec4.USRX14
     , SDD_MTI_rec4.USRX15
     , SDD_MTI_rec4.USRX16
     , SDD_MTI_rec4.USRX17
     , SDD_MTI_rec4.USRX18
     , SDD_MTI_rec4.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_MTI_rec4.irid, SDD_MTI_rec4.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_CNU_rec5 in SDD_CNU_cur5 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_CNU
    values (
       SDD_CNU_rec5.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_CNU_rec5.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_CNU_rec5.TYPES
     , SDD_CNU_rec5.ELEMENT_TYPE_NAME
     , SDD_CNU_rec5.DATE_CREATED
     , SDD_CNU_rec5.CREATED_BY
     , SDD_CNU_rec5.DATE_CHANGED
     , SDD_CNU_rec5.CHANGED_BY
     , SDD_CNU_rec5.NOTM
     , SDD_CNU_rec5.CONSTRAINT_REF
     , SDD_CNU_rec5.TABLE_USAGE_REF
    );
  jr_reg_ver.vercopy_dependencies(SDD_CNU_rec5.irid, SDD_CNU_rec5.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_MUN_rec6 in SDD_MUN_cur6 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_MUN
    values (
       SDD_MUN_rec6.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_MUN_rec6.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_MUN_rec6.TYPES
     , SDD_MUN_rec6.ELEMENT_TYPE_NAME
     , SDD_MUN_rec6.DATE_CREATED
     , SDD_MUN_rec6.CREATED_BY
     , SDD_MUN_rec6.DATE_CHANGED
     , SDD_MUN_rec6.CHANGED_BY
     , SDD_MUN_rec6.NOTM
     , SDD_MUN_rec6.GENERAL_MODULE_REF
     , SDD_MUN_rec6.MODULE_COMPONENT_REF
     , SDD_MUN_rec6.NAME
     , SDD_MUN_rec6.SHORT_DESCRIPTION
     , SDD_MUN_rec6.IMPLEMENTATION_ITEM
     , SDD_MUN_rec6.LANGUAGE_REF
     , SDD_MUN_rec6.MODULE_LEVEL_FLAG
     , SDD_MUN_rec6.DATASOURCE_TYPE
     , SDD_MUN_rec6.DATATARGET_TYPE
     , SDD_MUN_rec6.INSERT_FLAG
     , SDD_MUN_rec6.DELETE_FLAG
     , SDD_MUN_rec6.UPDATE_FLAG
     , SDD_MUN_rec6.SELECT_FLAG
     , SDD_MUN_rec6.AUTOQUERY_FLAG
     , SDD_MUN_rec6.DISPLAY_TITLE
     , SDD_MUN_rec6.LAYOUT_STYLE
     , SDD_MUN_rec6.ROWS_DISPLAYED
     , SDD_MUN_rec6.REQ_OVERFLOW
     , SDD_MUN_rec6.REQ_PAGE_WIDTH
     , SDD_MUN_rec6.REQ_PAGE_HEIGHT
     , SDD_MUN_rec6.REQ_VIEW_WIDTH
     , SDD_MUN_rec6.REQ_VIEW_HEIGHT
     , SDD_MUN_rec6.MODULE_UNIT_SUBTYPE
     , SDD_MUN_rec6.HELP_CONTEXT_ID_PREFIX
     , SDD_MUN_rec6.RUNTIME_PATHNAME
     , SDD_MUN_rec6.HELP_CONTEXT_ID_SUFFIX
     , SDD_MUN_rec6.USRX0
     , SDD_MUN_rec6.USRX1
     , SDD_MUN_rec6.USRX2
     , SDD_MUN_rec6.USRX3
     , SDD_MUN_rec6.USRX4
     , SDD_MUN_rec6.USRX5
     , SDD_MUN_rec6.USRX6
     , SDD_MUN_rec6.USRX7
     , SDD_MUN_rec6.USRX8
     , SDD_MUN_rec6.USRX9
     , SDD_MUN_rec6.USRX10
     , SDD_MUN_rec6.USRX11
     , SDD_MUN_rec6.USRX12
     , SDD_MUN_rec6.USRX13
     , SDD_MUN_rec6.USRX14
     , SDD_MUN_rec6.USRX15
     , SDD_MUN_rec6.USRX16
     , SDD_MUN_rec6.USRX17
     , SDD_MUN_rec6.USRX18
     , SDD_MUN_rec6.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_MUN_rec6.irid, SDD_MUN_rec6.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_SQS_rec7 in SDD_SQS_cur7 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_SQS
    values (
       SDD_SQS_rec7.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_SQS_rec7.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_SQS_rec7.TYPES
     , SDD_SQS_rec7.ELEMENT_TYPE_NAME
     , SDD_SQS_rec7.DATE_CREATED
     , SDD_SQS_rec7.CREATED_BY
     , SDD_SQS_rec7.DATE_CHANGED
     , SDD_SQS_rec7.CHANGED_BY
     , SDD_SQS_rec7.NOTM
     , SDD_SQS_rec7.MODULE_COMPONENT_REF
     , SDD_SQS_rec7.LIST_OF_VALUES_REF
     , SDD_SQS_rec7.NAME
     , SDD_SQS_rec7.SEQUENCE_NUMBER
     , SDD_SQS_rec7.USRX0
     , SDD_SQS_rec7.USRX1
     , SDD_SQS_rec7.USRX2
     , SDD_SQS_rec7.USRX3
     , SDD_SQS_rec7.USRX4
     , SDD_SQS_rec7.USRX5
     , SDD_SQS_rec7.USRX6
     , SDD_SQS_rec7.USRX7
     , SDD_SQS_rec7.USRX8
     , SDD_SQS_rec7.USRX9
     , SDD_SQS_rec7.USRX10
     , SDD_SQS_rec7.USRX11
     , SDD_SQS_rec7.USRX12
     , SDD_SQS_rec7.USRX13
     , SDD_SQS_rec7.USRX14
     , SDD_SQS_rec7.USRX15
     , SDD_SQS_rec7.USRX16
     , SDD_SQS_rec7.USRX17
     , SDD_SQS_rec7.USRX18
     , SDD_SQS_rec7.USRX19
     , SDD_SQS_rec7.SQL_QUERY_SET_FOR
    );
  jr_reg_ver.vercopy_dependencies(SDD_SQS_rec7.irid, SDD_SQS_rec7.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  jr_reg_ver.vercopy_dependent_objects(SDD_MUN_ver.ivid, new_ivid);
  return new_ivid;
end SDD_MUN_ver;
/
create or replace function PK_SDD_MUN (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_MUN the_tab_new, SDD_MUN the_tab_old
  where  the_tab_new.ivid = PK_SDD_MUN.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_MUN.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_MUN;
/
create or replace function FK_MUN_TO_GEM (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.GENERAL_MODULE_REF ref_value
  from   i$SDD_MUN the_tab
  where  the_tab.ivid = FK_MUN_TO_GEM.object_ivid
  and    the_tab.GENERAL_MODULE_REF is not null
  and    not exists (
             select null
             from   SDD_MOD foreign_tab
             where  the_tab.GENERAL_MODULE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5022, action);
  end loop;
  return is_ok;
end FK_MUN_TO_GEM;
/
create or replace function FK_MUN_TO_LAN (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.LANGUAGE_REF ref_value
  from   i$SDD_MUN the_tab
  where  the_tab.ivid = FK_MUN_TO_LAN.object_ivid
  and    the_tab.LANGUAGE_REF is not null
  and    not exists (
             select null
             from   SDD_LAN foreign_tab
             where  the_tab.LANGUAGE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4996, action);
  end loop;
  return is_ok;
end FK_MUN_TO_LAN;
/
create or replace function FK_MUN_TO_MCO (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.MODULE_COMPONENT_REF ref_value
  from   i$SDD_MUN the_tab
  where  the_tab.ivid = FK_MUN_TO_MCO.object_ivid
  and    the_tab.MODULE_COMPONENT_REF is not null
  and    not exists (
             select null
             from   SDD_MUN foreign_tab
             where  the_tab.MODULE_COMPONENT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5051, action);
  end loop;
  return is_ok;
end FK_MUN_TO_MCO;
/
create or replace function PK_SDD_MWF (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_MWF the_tab_new, SDD_MWF the_tab_old
  where  the_tab_new.ivid = PK_SDD_MWF.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_MWF.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_MWF;
/
create or replace function FK_TAB_TO_OCL_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_TAB child_tab
  where  child_tab.CLUSTER_REF=FK_TAB_TO_OCL_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_TAB child_tab, i$sdd_object_versions o
    where  child_tab.CLUSTER_REF=FK_TAB_TO_OCL_d.IRID
    and    child_tab.ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_TAB_TO_OCL_d;
/
create or replace function SDD_OCL_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_OCL_cur is
    select *
    from   i$SDD_OCL the_tab
    where  the_tab.irid=SDD_OCL_ver.irid
    and    the_tab.ivid=SDD_OCL_ver.ivid;
  SDD_OCL_rec SDD_OCL_cur%ROWTYPE;
  cursor SDD_CCD_cur1 is
    select *
    from i$SDD_CCD the_tab
    where the_tab.parent_ivid=SDD_OCL_ver.ivid;
  cursor SDD_IND_cur2 is
    select *
    from i$SDD_IND the_tab
    where the_tab.parent_ivid=SDD_OCL_ver.ivid;
  cursor SDD_INDCOL_cur3 is
    select *
    from i$SDD_INDCOL the_tab
    where the_tab.parent_ivid=SDD_OCL_ver.ivid;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_OCL_cur;
  fetch SDD_OCL_cur into SDD_OCL_rec;
  close SDD_OCL_cur;
  insert into i$SDD_OCL
  values (
    SDD_OCL_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_OCL_rec.TYPES
   ,SDD_OCL_rec.ELEMENT_TYPE_NAME
   ,SDD_OCL_rec.DATE_CREATED
   ,SDD_OCL_rec.CREATED_BY
   ,SDD_OCL_rec.DATE_CHANGED
   ,SDD_OCL_rec.CHANGED_BY
   ,SDD_OCL_rec.NOTM
   ,SDD_OCL_rec.NAME
   ,SDD_OCL_rec.CLUSTER_TYPE
   ,SDD_OCL_rec.CLUSTER_SIZE
   ,SDD_OCL_rec.HASHKEYS
   ,SDD_OCL_rec.HASH_IS
   ,SDD_OCL_rec.REMARK
   ,SDD_OCL_rec.USRX0
   ,SDD_OCL_rec.USRX1
   ,SDD_OCL_rec.USRX2
   ,SDD_OCL_rec.USRX3
   ,SDD_OCL_rec.USRX4
   ,SDD_OCL_rec.USRX5
   ,SDD_OCL_rec.USRX6
   ,SDD_OCL_rec.USRX7
   ,SDD_OCL_rec.USRX8
   ,SDD_OCL_rec.USRX9
   ,SDD_OCL_rec.USRX10
   ,SDD_OCL_rec.USRX11
   ,SDD_OCL_rec.USRX12
   ,SDD_OCL_rec.USRX13
   ,SDD_OCL_rec.USRX14
   ,SDD_OCL_rec.USRX15
   ,SDD_OCL_rec.USRX16
   ,SDD_OCL_rec.USRX17
   ,SDD_OCL_rec.USRX18
   ,SDD_OCL_rec.USRX19
  );
  jr_reg_ver.vercopy_dependencies(SDD_OCL_ver.irid, SDD_OCL_ver.ivid, new_ivid, null, copy_dependencies);
  for SDD_CCD_rec1 in SDD_CCD_cur1 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_CCD
    values (
       SDD_CCD_rec1.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_CCD_rec1.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_CCD_rec1.TYPES
     , SDD_CCD_rec1.ELEMENT_TYPE_NAME
     , SDD_CCD_rec1.DATE_CREATED
     , SDD_CCD_rec1.CREATED_BY
     , SDD_CCD_rec1.DATE_CHANGED
     , SDD_CCD_rec1.CHANGED_BY
     , SDD_CCD_rec1.NOTM
     , SDD_CCD_rec1.CLUSTER_REF
     , SDD_CCD_rec1.NAME
     , SDD_CCD_rec1.SEQUENCE_NUMBER
     , SDD_CCD_rec1.DATATYPE
     , SDD_CCD_rec1.LENGTH
     , SDD_CCD_rec1.SCALE
     , SDD_CCD_rec1.USRX0
     , SDD_CCD_rec1.USRX1
     , SDD_CCD_rec1.USRX2
     , SDD_CCD_rec1.USRX3
     , SDD_CCD_rec1.USRX4
     , SDD_CCD_rec1.USRX5
     , SDD_CCD_rec1.USRX6
     , SDD_CCD_rec1.USRX7
     , SDD_CCD_rec1.USRX8
     , SDD_CCD_rec1.USRX9
     , SDD_CCD_rec1.USRX10
     , SDD_CCD_rec1.USRX11
     , SDD_CCD_rec1.USRX12
     , SDD_CCD_rec1.USRX13
     , SDD_CCD_rec1.USRX14
     , SDD_CCD_rec1.USRX15
     , SDD_CCD_rec1.USRX16
     , SDD_CCD_rec1.USRX17
     , SDD_CCD_rec1.USRX18
     , SDD_CCD_rec1.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_CCD_rec1.irid, SDD_CCD_rec1.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_IND_rec2 in SDD_IND_cur2 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_IND
    values (
       SDD_IND_rec2.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_IND_rec2.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_IND_rec2.TYPES
     , SDD_IND_rec2.ELEMENT_TYPE_NAME
     , SDD_IND_rec2.DATE_CREATED
     , SDD_IND_rec2.CREATED_BY
     , SDD_IND_rec2.DATE_CHANGED
     , SDD_IND_rec2.CHANGED_BY
     , SDD_IND_rec2.NOTM
     , SDD_IND_rec2.TABLE_DEFINITION_REF
     , SDD_IND_rec2.SNAPSHOT_DEFINITION_REF
     , SDD_IND_rec2.CLUSTER_REF
     , SDD_IND_rec2.NAME
     , SDD_IND_rec2.RELATION_INDEX_TYPE
     , SDD_IND_rec2.COMPLETE_FLAG
     , SDD_IND_rec2.COMPUTE_STATISTICS_FLAG
     , SDD_IND_rec2.FOREIGN_KEY_REF
     , SDD_IND_rec2.REMARK
     , SDD_IND_rec2.INDEX_TYPE
     , SDD_IND_rec2.RELATION_INDEX_FOR
     , SDD_IND_rec2.USRX0
     , SDD_IND_rec2.USRX1
     , SDD_IND_rec2.USRX2
     , SDD_IND_rec2.USRX3
     , SDD_IND_rec2.USRX4
     , SDD_IND_rec2.USRX5
     , SDD_IND_rec2.USRX6
     , SDD_IND_rec2.USRX7
     , SDD_IND_rec2.USRX8
     , SDD_IND_rec2.USRX9
     , SDD_IND_rec2.USRX10
     , SDD_IND_rec2.USRX11
     , SDD_IND_rec2.USRX12
     , SDD_IND_rec2.USRX13
     , SDD_IND_rec2.USRX14
     , SDD_IND_rec2.USRX15
     , SDD_IND_rec2.USRX16
     , SDD_IND_rec2.USRX17
     , SDD_IND_rec2.USRX18
     , SDD_IND_rec2.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_IND_rec2.irid, SDD_IND_rec2.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_INDCOL_rec3 in SDD_INDCOL_cur3 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_INDCOL
    values (
       SDD_INDCOL_rec3.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_INDCOL_rec3.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_INDCOL_rec3.TYPES
     , SDD_INDCOL_rec3.ELEMENT_TYPE_NAME
     , SDD_INDCOL_rec3.DATE_CREATED
     , SDD_INDCOL_rec3.CREATED_BY
     , SDD_INDCOL_rec3.DATE_CHANGED
     , SDD_INDCOL_rec3.CHANGED_BY
     , SDD_INDCOL_rec3.NOTM
     , SDD_INDCOL_rec3.RELATION_INDEX_REF
     , SDD_INDCOL_rec3.COLUMN_REF
     , SDD_INDCOL_rec3.SEQUENCE_NUMBER
     , SDD_INDCOL_rec3.INDEX_FUNCTION
     , SDD_INDCOL_rec3.INDEX_ENTRY_TYPE
     , SDD_INDCOL_rec3.NAME
     , SDD_INDCOL_rec3.CQA_REF
     , SDD_INDCOL_rec3.INDEX_ENTRY_FOR
     , SDD_INDCOL_rec3.USRX0
     , SDD_INDCOL_rec3.USRX1
     , SDD_INDCOL_rec3.USRX2
     , SDD_INDCOL_rec3.USRX3
     , SDD_INDCOL_rec3.USRX4
     , SDD_INDCOL_rec3.USRX5
     , SDD_INDCOL_rec3.USRX6
     , SDD_INDCOL_rec3.USRX7
     , SDD_INDCOL_rec3.USRX8
     , SDD_INDCOL_rec3.USRX9
     , SDD_INDCOL_rec3.USRX10
     , SDD_INDCOL_rec3.USRX11
     , SDD_INDCOL_rec3.USRX12
     , SDD_INDCOL_rec3.USRX13
     , SDD_INDCOL_rec3.USRX14
     , SDD_INDCOL_rec3.USRX15
     , SDD_INDCOL_rec3.USRX16
     , SDD_INDCOL_rec3.USRX17
     , SDD_INDCOL_rec3.USRX18
     , SDD_INDCOL_rec3.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_INDCOL_rec3.irid, SDD_INDCOL_rec3.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  jr_reg_ver.vercopy_dependent_objects(SDD_OCL_ver.ivid, new_ivid);
  return new_ivid;
end SDD_OCL_ver;
/
create or replace function PK_SDD_OCL (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_OCL the_tab_new, SDD_OCL the_tab_old
  where  the_tab_new.ivid = PK_SDD_OCL.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_OCL.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_OCL;
/
create or replace function FK_MCL_TO_JCO_cmd (irid number, ivid number) return boolean as
cursor bad_cur is
  select child_tab.irid child_irid, child_tab.types child_type
        ,parent_tab.ivid par_ivid, parent_tab.types par_type
  from   SDD_MCL child_tab, i$SDD_OCO parent_tab
  where  parent_tab.parent_ivid=FK_MCL_TO_JCO_cmd.ivid
  and    child_tab.JOIN_CONSTRAINT_REF=parent_tab.IRID
  ;
  is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
   insert into I$SDD_INVALID_OBJECTS(object_irid,object_ivid,table_irid)
    select o.irid,o.ivid,o.table_irid
      from SDD_MCL child_tab
          ,i$SDD_OCO parent_tab
          ,I$SDD_OBJECT_VERSIONS o
     where parent_tab.parent_ivid=FK_MCL_TO_JCO_cmd.ivid
       and child_tab.JOIN_CONSTRAINT_REF=parent_tab.IRID
       and child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(ref.par_ivid,ref.par_type,ref.child_irid,ref.child_type,'DEL');
  end loop;
  return is_ok;
end FK_MCL_TO_JCO_cmd;
/
create or replace function FK_MCL_TO_JCO_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_MCL child_tab
  where  child_tab.JOIN_CONSTRAINT_REF=FK_MCL_TO_JCO_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_MCL child_tab, i$sdd_object_versions o
    where  child_tab.JOIN_CONSTRAINT_REF=FK_MCL_TO_JCO_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_MCL_TO_JCO_d;
/
create or replace function FK_MCL_TO_PCO_cmd (irid number, ivid number) return boolean as
cursor bad_cur is
  select child_tab.irid child_irid, child_tab.types child_type
        ,parent_tab.ivid par_ivid, parent_tab.types par_type
  from   SDD_MCL child_tab, i$SDD_OCO parent_tab
  where  parent_tab.parent_ivid=FK_MCL_TO_PCO_cmd.ivid
  and    child_tab.PRIMARY_KEY_REF=parent_tab.IRID
  ;
  is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
   insert into I$SDD_INVALID_OBJECTS(object_irid,object_ivid,table_irid)
    select o.irid,o.ivid,o.table_irid
      from SDD_MCL child_tab
          ,i$SDD_OCO parent_tab
          ,I$SDD_OBJECT_VERSIONS o
     where parent_tab.parent_ivid=FK_MCL_TO_PCO_cmd.ivid
       and child_tab.PRIMARY_KEY_REF=parent_tab.IRID
       and child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(ref.par_ivid,ref.par_type,ref.child_irid,ref.child_type,'DEL');
  end loop;
  return is_ok;
end FK_MCL_TO_PCO_cmd;
/
create or replace function FK_MCL_TO_PCO_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_MCL child_tab
  where  child_tab.PRIMARY_KEY_REF=FK_MCL_TO_PCO_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_MCL child_tab, i$sdd_object_versions o
    where  child_tab.PRIMARY_KEY_REF=FK_MCL_TO_PCO_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_MCL_TO_PCO_d;
/
create or replace function FK_MTI_TO_JCO_cmd (irid number, ivid number) return boolean as
cursor bad_cur is
  select child_tab.irid child_irid, child_tab.types child_type
        ,parent_tab.ivid par_ivid, parent_tab.types par_type
  from   SDD_MTI child_tab, i$SDD_OCO parent_tab
  where  parent_tab.parent_ivid=FK_MTI_TO_JCO_cmd.ivid
  and    child_tab.CONSTRAINT_REF=parent_tab.IRID
  ;
  is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
   insert into I$SDD_INVALID_OBJECTS(object_irid,object_ivid,table_irid)
    select o.irid,o.ivid,o.table_irid
      from SDD_MTI child_tab
          ,i$SDD_OCO parent_tab
          ,I$SDD_OBJECT_VERSIONS o
     where parent_tab.parent_ivid=FK_MTI_TO_JCO_cmd.ivid
       and child_tab.CONSTRAINT_REF=parent_tab.IRID
       and child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(ref.par_ivid,ref.par_type,ref.child_irid,ref.child_type,'DEL');
  end loop;
  return is_ok;
end FK_MTI_TO_JCO_cmd;
/
create or replace function FK_MTI_TO_JCO_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_MTI child_tab
  where  child_tab.CONSTRAINT_REF=FK_MTI_TO_JCO_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_MTI child_tab, i$sdd_object_versions o
    where  child_tab.CONSTRAINT_REF=FK_MTI_TO_JCO_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_MTI_TO_JCO_d;
/
create or replace function PK_SDD_OCO (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_OCO the_tab_new, SDD_OCO the_tab_old
  where  the_tab_new.ivid = PK_SDD_OCO.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_OCO.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_OCO;
/
create or replace function FK_OCO_TO_PCO (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.PRIMARY_KEY_REF ref_value
  from   i$SDD_OCO the_tab
  where  the_tab.ivid = FK_OCO_TO_PCO.object_ivid
  and    the_tab.PRIMARY_KEY_REF is not null
  and    not exists (
             select null
             from   SDD_OCO foreign_tab
             where  the_tab.PRIMARY_KEY_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5027, action);
  end loop;
  return is_ok;
end FK_OCO_TO_PCO;
/
create or replace function FK_OCO_TO_RELEND (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.RELATIONSHIP_END_REF ref_value
  from   i$SDD_OCO the_tab
  where  the_tab.ivid = FK_OCO_TO_RELEND.object_ivid
  and    the_tab.RELATIONSHIP_END_REF is not null
  and    not exists (
             select null
             from   SDD_RELEND foreign_tab
             where  the_tab.RELATIONSHIP_END_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5025, action);
  end loop;
  return is_ok;
end FK_OCO_TO_RELEND;
/
create or replace function FK_OCO_TO_TAB2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.FOREIGN_TABLE_REF ref_value
  from   i$SDD_OCO the_tab
  where  the_tab.ivid = FK_OCO_TO_TAB2.object_ivid
  and    the_tab.FOREIGN_TABLE_REF is not null
  and    not exists (
             select null
             from   SDD_TAB foreign_tab
             where  the_tab.FOREIGN_TABLE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4982, action);
  end loop;
  return is_ok;
end FK_OCO_TO_TAB2;
/
create or replace function FK_OCO_TO_UCO (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.UNIQUE_KEY_REF ref_value
  from   i$SDD_OCO the_tab
  where  the_tab.ivid = FK_OCO_TO_UCO.object_ivid
  and    the_tab.UNIQUE_KEY_REF is not null
  and    not exists (
             select null
             from   SDD_OCO foreign_tab
             where  the_tab.UNIQUE_KEY_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5027, action);
  end loop;
  return is_ok;
end FK_OCO_TO_UCO;
/
create or replace function FK_OCO_TO_UID (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.UNIQUE_IDENTIFIER_REF ref_value
  from   i$SDD_OCO the_tab
  where  the_tab.ivid = FK_OCO_TO_UID.object_ivid
  and    the_tab.UNIQUE_IDENTIFIER_REF is not null
  and    not exists (
             select null
             from   SDD_UID foreign_tab
             where  the_tab.UNIQUE_IDENTIFIER_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4877, action);
  end loop;
  return is_ok;
end FK_OCO_TO_UID;
/
create or replace function SDD_ODB_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_ODB_cur is
    select *
    from   i$SDD_ODB the_tab
    where  the_tab.irid=SDD_ODB_ver.irid
    and    the_tab.ivid=SDD_ODB_ver.ivid;
  SDD_ODB_rec SDD_ODB_cur%ROWTYPE;
  cursor SDD_DBU_cur1 is
    select *
    from i$SDD_DBU the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_DBUGRP_cur2 is
    select *
    from i$SDD_DBUGRP the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_DBUMOD_cur3 is
    select *
    from i$SDD_DBUMOD the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_DOG_cur4 is
    select *
    from i$SDD_DOG the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_DOI_cur5 is
    select *
    from i$SDD_DOI the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_BRL_cur6 is
    select *
    from i$SDD_BRL the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_CST_cur7 is
    select *
    from i$SDD_CST the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_INS_cur8 is
    select *
    from i$SDD_INS the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_INP_cur9 is
    select *
    from i$SDD_INP the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_TBICOL_cur10 is
    select *
    from i$SDD_TBICOL the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_TBP_cur11 is
    select *
    from i$SDD_TBP the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_SPV_cur12 is
    select *
    from i$SDD_SPV the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_TSQ_cur13 is
    select *
    from i$SDD_TSQ the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_DFI_cur14 is
    select *
    from i$SDD_DFI the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_DIR_cur15 is
    select *
    from i$SDD_DIR the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_DPR_cur16 is
    select *
    from i$SDD_DPR the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_GRP_cur17 is
    select *
    from i$SDD_GRP the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_GRPGRP_cur18 is
    select *
    from i$SDD_GRPGRP the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_GRPMOD_cur19 is
    select *
    from i$SDD_GRPMOD the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_LST_cur20 is
    select *
    from i$SDD_LST the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_ODBODB_cur21 is
    select *
    from i$SDD_ODBODB the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_ORS_cur22 is
    select *
    from i$SDD_ORS the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_OTB_cur23 is
    select *
    from i$SDD_OTB the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_QUI_cur24 is
    select *
    from i$SDD_QUI the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_QSU_cur25 is
    select *
    from i$SDD_QSU the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_RPG_cur26 is
    select *
    from i$SDD_RPG the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_RGP_cur27 is
    select *
    from i$SDD_RGP the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
  cursor SDD_SRG_cur28 is
    select *
    from i$SDD_SRG the_tab
    where the_tab.parent_ivid=SDD_ODB_ver.ivid;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_ODB_cur;
  fetch SDD_ODB_cur into SDD_ODB_rec;
  close SDD_ODB_cur;
  insert into i$SDD_ODB
  values (
    SDD_ODB_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_ODB_rec.TYPES
   ,SDD_ODB_rec.ELEMENT_TYPE_NAME
   ,SDD_ODB_rec.DATE_CREATED
   ,SDD_ODB_rec.CREATED_BY
   ,SDD_ODB_rec.DATE_CHANGED
   ,SDD_ODB_rec.CHANGED_BY
   ,SDD_ODB_rec.NOTM
   ,SDD_ODB_rec.NAME
   ,SDD_ODB_rec.LOCAL_NAME
   ,SDD_ODB_rec.DB_VERSION
   ,SDD_ODB_rec.NON_ORACLE_DATABASE_TYPE
   ,SDD_ODB_rec.CHARACTER_SET
   ,SDD_ODB_rec.COMPLETE_FLAG
   ,SDD_ODB_rec.NODE_REF
   ,SDD_ODB_rec.TNS_ALIAS
   ,SDD_ODB_rec.CONNECT_STRING
   ,SDD_ODB_rec.SHARED_FLAG
   ,SDD_ODB_rec.MAX_DATABASE_INSTANCES
   ,SDD_ODB_rec.REUSE_CONTROL_FILE
   ,SDD_ODB_rec.MAX_DATA_FILES
   ,SDD_ODB_rec.ARCHIVE_REDO_LOG_FILES
   ,SDD_ODB_rec.MAX_LOG_FILES
   ,SDD_ODB_rec.MAX_LOG_HISTORY
   ,SDD_ODB_rec.MAX_LOG_MEMBERS
   ,SDD_ODB_rec.REMARK
   ,SDD_ODB_rec.DATABASE_TYPE
   ,SDD_ODB_rec.USRX0
   ,SDD_ODB_rec.USRX1
   ,SDD_ODB_rec.USRX2
   ,SDD_ODB_rec.USRX3
   ,SDD_ODB_rec.USRX4
   ,SDD_ODB_rec.USRX5
   ,SDD_ODB_rec.USRX6
   ,SDD_ODB_rec.USRX7
   ,SDD_ODB_rec.USRX8
   ,SDD_ODB_rec.USRX9
   ,SDD_ODB_rec.USRX10
   ,SDD_ODB_rec.USRX11
   ,SDD_ODB_rec.USRX12
   ,SDD_ODB_rec.USRX13
   ,SDD_ODB_rec.USRX14
   ,SDD_ODB_rec.USRX15
   ,SDD_ODB_rec.USRX16
   ,SDD_ODB_rec.USRX17
   ,SDD_ODB_rec.USRX18
   ,SDD_ODB_rec.USRX19
  );
  jr_reg_ver.vercopy_dependencies(SDD_ODB_ver.irid, SDD_ODB_ver.ivid, new_ivid, null, copy_dependencies);
  for SDD_DBU_rec1 in SDD_DBU_cur1 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DBU
    values (
       SDD_DBU_rec1.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DBU_rec1.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DBU_rec1.TYPES
     , SDD_DBU_rec1.ELEMENT_TYPE_NAME
     , SDD_DBU_rec1.DATE_CREATED
     , SDD_DBU_rec1.CREATED_BY
     , SDD_DBU_rec1.DATE_CHANGED
     , SDD_DBU_rec1.CHANGED_BY
     , SDD_DBU_rec1.NOTM
     , SDD_DBU_rec1.DATABASE_REF
     , SDD_DBU_rec1.NAME
     , SDD_DBU_rec1.INITIAL_PASSWORD
     , SDD_DBU_rec1.COMPLETE_FLAG
     , SDD_DBU_rec1.DATABASE_PROFILE_REF
     , SDD_DBU_rec1.DEFAULT_TABLESPACE_REF
     , SDD_DBU_rec1.TEMP_TABLESPACE_REF
     , SDD_DBU_rec1.REMARK
     , SDD_DBU_rec1.USRX0
     , SDD_DBU_rec1.USRX1
     , SDD_DBU_rec1.USRX2
     , SDD_DBU_rec1.USRX3
     , SDD_DBU_rec1.USRX4
     , SDD_DBU_rec1.USRX5
     , SDD_DBU_rec1.USRX6
     , SDD_DBU_rec1.USRX7
     , SDD_DBU_rec1.USRX8
     , SDD_DBU_rec1.USRX9
     , SDD_DBU_rec1.USRX10
     , SDD_DBU_rec1.USRX11
     , SDD_DBU_rec1.USRX12
     , SDD_DBU_rec1.USRX13
     , SDD_DBU_rec1.USRX14
     , SDD_DBU_rec1.USRX15
     , SDD_DBU_rec1.USRX16
     , SDD_DBU_rec1.USRX17
     , SDD_DBU_rec1.USRX18
     , SDD_DBU_rec1.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DBU_rec1.irid, SDD_DBU_rec1.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_DBUGRP_rec2 in SDD_DBUGRP_cur2 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DBUGRP
    values (
       SDD_DBUGRP_rec2.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DBUGRP_rec2.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DBUGRP_rec2.TYPES
     , SDD_DBUGRP_rec2.ELEMENT_TYPE_NAME
     , SDD_DBUGRP_rec2.DATE_CREATED
     , SDD_DBUGRP_rec2.CREATED_BY
     , SDD_DBUGRP_rec2.DATE_CHANGED
     , SDD_DBUGRP_rec2.CHANGED_BY
     , SDD_DBUGRP_rec2.NOTM
     , SDD_DBUGRP_rec2.DATABASE_USER_REF
     , SDD_DBUGRP_rec2.ROLE_REF
     , SDD_DBUGRP_rec2.WITH_GRANT_OPT_IND
     , SDD_DBUGRP_rec2.USRX0
     , SDD_DBUGRP_rec2.USRX1
     , SDD_DBUGRP_rec2.USRX2
     , SDD_DBUGRP_rec2.USRX3
     , SDD_DBUGRP_rec2.USRX4
     , SDD_DBUGRP_rec2.USRX5
     , SDD_DBUGRP_rec2.USRX6
     , SDD_DBUGRP_rec2.USRX7
     , SDD_DBUGRP_rec2.USRX8
     , SDD_DBUGRP_rec2.USRX9
     , SDD_DBUGRP_rec2.USRX10
     , SDD_DBUGRP_rec2.USRX11
     , SDD_DBUGRP_rec2.USRX12
     , SDD_DBUGRP_rec2.USRX13
     , SDD_DBUGRP_rec2.USRX14
     , SDD_DBUGRP_rec2.USRX15
     , SDD_DBUGRP_rec2.USRX16
     , SDD_DBUGRP_rec2.USRX17
     , SDD_DBUGRP_rec2.USRX18
     , SDD_DBUGRP_rec2.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DBUGRP_rec2.irid, SDD_DBUGRP_rec2.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_DBUMOD_rec3 in SDD_DBUMOD_cur3 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DBUMOD
    values (
       SDD_DBUMOD_rec3.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DBUMOD_rec3.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DBUMOD_rec3.TYPES
     , SDD_DBUMOD_rec3.ELEMENT_TYPE_NAME
     , SDD_DBUMOD_rec3.DATE_CREATED
     , SDD_DBUMOD_rec3.CREATED_BY
     , SDD_DBUMOD_rec3.DATE_CHANGED
     , SDD_DBUMOD_rec3.CHANGED_BY
     , SDD_DBUMOD_rec3.NOTM
     , SDD_DBUMOD_rec3.DATABASE_USER_REF
     , SDD_DBUMOD_rec3.GENERAL_MODULE_REF
     , SDD_DBUMOD_rec3.WITH_GRANT_OPT_IND
     , SDD_DBUMOD_rec3.USRX0
     , SDD_DBUMOD_rec3.USRX1
     , SDD_DBUMOD_rec3.USRX2
     , SDD_DBUMOD_rec3.USRX3
     , SDD_DBUMOD_rec3.USRX4
     , SDD_DBUMOD_rec3.USRX5
     , SDD_DBUMOD_rec3.USRX6
     , SDD_DBUMOD_rec3.USRX7
     , SDD_DBUMOD_rec3.USRX8
     , SDD_DBUMOD_rec3.USRX9
     , SDD_DBUMOD_rec3.USRX10
     , SDD_DBUMOD_rec3.USRX11
     , SDD_DBUMOD_rec3.USRX12
     , SDD_DBUMOD_rec3.USRX13
     , SDD_DBUMOD_rec3.USRX14
     , SDD_DBUMOD_rec3.USRX15
     , SDD_DBUMOD_rec3.USRX16
     , SDD_DBUMOD_rec3.USRX17
     , SDD_DBUMOD_rec3.USRX18
     , SDD_DBUMOD_rec3.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DBUMOD_rec3.irid, SDD_DBUMOD_rec3.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_DOG_rec4 in SDD_DOG_cur4 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DOG
    values (
       SDD_DOG_rec4.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DOG_rec4.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DOG_rec4.TYPES
     , SDD_DOG_rec4.ELEMENT_TYPE_NAME
     , SDD_DOG_rec4.DATE_CREATED
     , SDD_DOG_rec4.CREATED_BY
     , SDD_DOG_rec4.DATE_CHANGED
     , SDD_DOG_rec4.CHANGED_BY
     , SDD_DOG_rec4.NOTM
     , SDD_DOG_rec4.DATABASE_USER_REF
     , SDD_DOG_rec4.ROLE_REF
     , SDD_DOG_rec4.TABLE_REF
     , SDD_DOG_rec4.VIEW_REF
     , SDD_DOG_rec4.SNAPSHOT_REF
     , SDD_DOG_rec4.SEQUENCE_REF
     , SDD_DOG_rec4.PLSQL_MODULE_REF
     , SDD_DOG_rec4.DIRECTORY_REF
     , SDD_DOG_rec4.JMI_REF
     , SDD_DOG_rec4.QUI_REF
     , SDD_DOG_rec4.CREATE_SYNONYM_FLAG
     , SDD_DOG_rec4.ALL_ACCESS_FLAG
     , SDD_DOG_rec4.SELECT_FLAG
     , SDD_DOG_rec4.INSERT_FLAG
     , SDD_DOG_rec4.UPDATE_FLAG
     , SDD_DOG_rec4.DELETE_FLAG
     , SDD_DOG_rec4.INDEX_FLAG
     , SDD_DOG_rec4.ALTER_FLAG
     , SDD_DOG_rec4.REFERENCE_FLAG
     , SDD_DOG_rec4.EXECUTE_FLAG
     , SDD_DOG_rec4.READ_FLAG
     , SDD_DOG_rec4.GRANT_ACCESS_FLAG
     , SDD_DOG_rec4.ENQUEUE_FLAG
     , SDD_DOG_rec4.DEQUEUE_FLAG
     , SDD_DOG_rec4.REMARK
     , SDD_DOG_rec4.GRANT_OPTION_FOR
     , SDD_DOG_rec4.GRANT_OPTION_TO
     , SDD_DOG_rec4.USRX0
     , SDD_DOG_rec4.USRX1
     , SDD_DOG_rec4.USRX2
     , SDD_DOG_rec4.USRX3
     , SDD_DOG_rec4.USRX4
     , SDD_DOG_rec4.USRX5
     , SDD_DOG_rec4.USRX6
     , SDD_DOG_rec4.USRX7
     , SDD_DOG_rec4.USRX8
     , SDD_DOG_rec4.USRX9
     , SDD_DOG_rec4.USRX10
     , SDD_DOG_rec4.USRX11
     , SDD_DOG_rec4.USRX12
     , SDD_DOG_rec4.USRX13
     , SDD_DOG_rec4.USRX14
     , SDD_DOG_rec4.USRX15
     , SDD_DOG_rec4.USRX16
     , SDD_DOG_rec4.USRX17
     , SDD_DOG_rec4.USRX18
     , SDD_DOG_rec4.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DOG_rec4.irid, SDD_DOG_rec4.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_DOI_rec5 in SDD_DOI_cur5 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DOI
    values (
       SDD_DOI_rec5.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DOI_rec5.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DOI_rec5.TYPES
     , SDD_DOI_rec5.ELEMENT_TYPE_NAME
     , SDD_DOI_rec5.DATE_CREATED
     , SDD_DOI_rec5.CREATED_BY
     , SDD_DOI_rec5.DATE_CHANGED
     , SDD_DOI_rec5.CHANGED_BY
     , SDD_DOI_rec5.NOTM
     , SDD_DOI_rec5.DATABASE_USER_REF
     , SDD_DOI_rec5.CLUSTER_REF
     , SDD_DOI_rec5.PLSQL_MODULE_REF
     , SDD_DOI_rec5.SEQUENCE_REF
     , SDD_DOI_rec5.SNAPSHOT_DEFINITION_REF
     , SDD_DOI_rec5.TABLE_DEFINITION_REF
     , SDD_DOI_rec5.VIEW_DEFINITION_REF
     , SDD_DOI_rec5.COMPLETE_FLAG
     , SDD_DOI_rec5.GLOBAL_SYNONYM_NAME
     , SDD_DOI_rec5.TABLESPACE_REF
     , SDD_DOI_rec5.SCOPE
     , SDD_DOI_rec5.STORAGE_DEFINITION_REF
     , SDD_DOI_rec5.INITIAL_TRANSACTION
     , SDD_DOI_rec5.MAXIMUM_TRANSACTION
     , SDD_DOI_rec5.QUEUE_TABLE_DEF_REF
     , SDD_DOI_rec5.JAVA_MODULE_REF
     , SDD_DOI_rec5.CREATE_CLASS_FROM
     , SDD_DOI_rec5.ORACLE_TYPE_DBU_REF
     , SDD_DOI_rec5.DATABASE_USER_REF2
     , SDD_DOI_rec5.USE_BLOB
     , SDD_DOI_rec5.DIRECTORY_REF
     , SDD_DOI_rec5.FILENAME
     , SDD_DOI_rec5.RESOLVE_FLAG
     , SDD_DOI_rec5.FORCE_FLAG
     , SDD_DOI_rec5.PERCENT_FREE
     , SDD_DOI_rec5.PERCENT_USED
     , SDD_DOI_rec5.CACHED
     , SDD_DOI_rec5.PARALLEL
     , SDD_DOI_rec5.DEGREE
     , SDD_DOI_rec5.INSTANCES
     , SDD_DOI_rec5.LOCKING_SEQUENCE
     , SDD_DOI_rec5.START_VALUE
     , SDD_DOI_rec5.INCREMENT_VALUE
     , SDD_DOI_rec5.CACHE_VALUE
     , SDD_DOI_rec5.CYCLE
     , SDD_DOI_rec5.SNAPSHOT_LOG_FLAG
     , SDD_DOI_rec5.SNAP_LOG_TABLESPACE_REF
     , SDD_DOI_rec5.SNAP_LOG_STORAGE_REF
     , SDD_DOI_rec5.SNAPSHOT_LOG_INIT_TRANS
     , SDD_DOI_rec5.SNAPSHOT_LOG_MAX_TRANS
     , SDD_DOI_rec5.SNAPSHOT_LOG_PERCENT_FREE
     , SDD_DOI_rec5.SNAPSHOT_LOG_PERCENT_USED
     , SDD_DOI_rec5.PCTTHRESHOLD
     , SDD_DOI_rec5.SORTING_ORDER
     , SDD_DOI_rec5.OVERFLOW_TABLESPACE_REF
     , SDD_DOI_rec5.REFRESH_START
     , SDD_DOI_rec5.REFRESH_TYPE
     , SDD_DOI_rec5.REFRESH_NEXT
     , SDD_DOI_rec5.SNAPSHOT_GROUP_REF
     , SDD_DOI_rec5.MINIMUM_VALUE
     , SDD_DOI_rec5.BUILD_TYPE
     , SDD_DOI_rec5.QUERY_REWRITE_INDICATOR
     , SDD_DOI_rec5.REPLICATION_GROUP_REF
     , SDD_DOI_rec5.MAXIMUM_VALUE
     , SDD_DOI_rec5.OBJECT_IMPLEMENTATION_TYPE
     , SDD_DOI_rec5.CLASS_SOURCE_LOCATION
     , SDD_DOI_rec5.USRX0
     , SDD_DOI_rec5.USRX1
     , SDD_DOI_rec5.USRX2
     , SDD_DOI_rec5.USRX3
     , SDD_DOI_rec5.USRX4
     , SDD_DOI_rec5.USRX5
     , SDD_DOI_rec5.USRX6
     , SDD_DOI_rec5.USRX7
     , SDD_DOI_rec5.USRX8
     , SDD_DOI_rec5.USRX9
     , SDD_DOI_rec5.USRX10
     , SDD_DOI_rec5.USRX11
     , SDD_DOI_rec5.USRX12
     , SDD_DOI_rec5.USRX13
     , SDD_DOI_rec5.USRX14
     , SDD_DOI_rec5.USRX15
     , SDD_DOI_rec5.USRX16
     , SDD_DOI_rec5.USRX17
     , SDD_DOI_rec5.USRX18
     , SDD_DOI_rec5.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DOI_rec5.irid, SDD_DOI_rec5.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_BRL_rec6 in SDD_BRL_cur6 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_BRL
    values (
       SDD_BRL_rec6.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_BRL_rec6.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_BRL_rec6.TYPES
     , SDD_BRL_rec6.ELEMENT_TYPE_NAME
     , SDD_BRL_rec6.DATE_CREATED
     , SDD_BRL_rec6.CREATED_BY
     , SDD_BRL_rec6.DATE_CHANGED
     , SDD_BRL_rec6.CHANGED_BY
     , SDD_BRL_rec6.NOTM
     , SDD_BRL_rec6.VIEW_IMPLEMENTATION_REF
     , SDD_BRL_rec6.SNAPSHOT_REF
     , SDD_BRL_rec6.RELATION_SELECTION_REF
     , SDD_BRL_rec6.DATABASE_USER_REF
     , SDD_BRL_rec6.BASE_RELATION_LOCATION_FOR
     , SDD_BRL_rec6.USRX0
     , SDD_BRL_rec6.USRX1
     , SDD_BRL_rec6.USRX2
     , SDD_BRL_rec6.USRX3
     , SDD_BRL_rec6.USRX4
     , SDD_BRL_rec6.USRX5
     , SDD_BRL_rec6.USRX6
     , SDD_BRL_rec6.USRX7
     , SDD_BRL_rec6.USRX8
     , SDD_BRL_rec6.USRX9
     , SDD_BRL_rec6.USRX10
     , SDD_BRL_rec6.USRX11
     , SDD_BRL_rec6.USRX12
     , SDD_BRL_rec6.USRX13
     , SDD_BRL_rec6.USRX14
     , SDD_BRL_rec6.USRX15
     , SDD_BRL_rec6.USRX16
     , SDD_BRL_rec6.USRX17
     , SDD_BRL_rec6.USRX18
     , SDD_BRL_rec6.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_BRL_rec6.irid, SDD_BRL_rec6.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_CST_rec7 in SDD_CST_cur7 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_CST
    values (
       SDD_CST_rec7.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_CST_rec7.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_CST_rec7.TYPES
     , SDD_CST_rec7.ELEMENT_TYPE_NAME
     , SDD_CST_rec7.DATE_CREATED
     , SDD_CST_rec7.CREATED_BY
     , SDD_CST_rec7.DATE_CHANGED
     , SDD_CST_rec7.CHANGED_BY
     , SDD_CST_rec7.NOTM
     , SDD_CST_rec7.TABLE_IMPLEMENTATION_REF
     , SDD_CST_rec7.COLUMN_REF
     , SDD_CST_rec7.CQA_REF
     , SDD_CST_rec7.LOB_STORAGE_REF
     , SDD_CST_rec7.LOB_SEGMENT_NAME
     , SDD_CST_rec7.LOB_INDEX_NAME
     , SDD_CST_rec7.STORAGE_TABLE_NAME
     , SDD_CST_rec7.TABLESPACE_REF
     , SDD_CST_rec7.STORAGE_DEFINITION_REF
     , SDD_CST_rec7.COLUMN_STORAGE_TYPE
     , SDD_CST_rec7.COLUMN_STORAGE_FOR
     , SDD_CST_rec7.USRX0
     , SDD_CST_rec7.USRX1
     , SDD_CST_rec7.USRX2
     , SDD_CST_rec7.USRX3
     , SDD_CST_rec7.USRX4
     , SDD_CST_rec7.USRX5
     , SDD_CST_rec7.USRX6
     , SDD_CST_rec7.USRX7
     , SDD_CST_rec7.USRX8
     , SDD_CST_rec7.USRX9
     , SDD_CST_rec7.USRX10
     , SDD_CST_rec7.USRX11
     , SDD_CST_rec7.USRX12
     , SDD_CST_rec7.USRX13
     , SDD_CST_rec7.USRX14
     , SDD_CST_rec7.USRX15
     , SDD_CST_rec7.USRX16
     , SDD_CST_rec7.USRX17
     , SDD_CST_rec7.USRX18
     , SDD_CST_rec7.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_CST_rec7.irid, SDD_CST_rec7.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_INS_rec8 in SDD_INS_cur8 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_INS
    values (
       SDD_INS_rec8.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_INS_rec8.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_INS_rec8.TYPES
     , SDD_INS_rec8.ELEMENT_TYPE_NAME
     , SDD_INS_rec8.DATE_CREATED
     , SDD_INS_rec8.NAME
     , SDD_INS_rec8.CREATED_BY
     , SDD_INS_rec8.DATE_CHANGED
     , SDD_INS_rec8.CHANGED_BY
     , SDD_INS_rec8.NOTM
     , SDD_INS_rec8.TABLE_IMPLEMENTATION_REF
     , SDD_INS_rec8.SNAPSHOT_REF
     , SDD_INS_rec8.CLUSTER_REF
     , SDD_INS_rec8.INDEX_REF
     , SDD_INS_rec8.PRIMARY_KEY_REF
     , SDD_INS_rec8.UNIQUE_KEY_REF
     , SDD_INS_rec8.INDEX_STORAGE_TYPE
     , SDD_INS_rec8.IMPLICIT_INDEX_TYPE
     , SDD_INS_rec8.TABLESPACE_REF
     , SDD_INS_rec8.STORAGE_DEFINITION_REF
     , SDD_INS_rec8.INITIAL_TRANSACTION
     , SDD_INS_rec8.MAXIMUM_TRANSACTION
     , SDD_INS_rec8.PERCENT_FREE
     , SDD_INS_rec8.REVERSE_OR_NOSORT
     , SDD_INS_rec8.PARALLEL
     , SDD_INS_rec8.DEGREE
     , SDD_INS_rec8.INSTANCES
     , SDD_INS_rec8.INDEX_STORAGE_ON
     , SDD_INS_rec8.INDEX_STORAGE_SUBTYPE
     , SDD_INS_rec8.INDEX_STORAGE_IMPLEMENTING
     , SDD_INS_rec8.USRX0
     , SDD_INS_rec8.USRX1
     , SDD_INS_rec8.USRX2
     , SDD_INS_rec8.USRX3
     , SDD_INS_rec8.USRX4
     , SDD_INS_rec8.USRX5
     , SDD_INS_rec8.USRX6
     , SDD_INS_rec8.USRX7
     , SDD_INS_rec8.USRX8
     , SDD_INS_rec8.USRX9
     , SDD_INS_rec8.USRX10
     , SDD_INS_rec8.USRX11
     , SDD_INS_rec8.USRX12
     , SDD_INS_rec8.USRX13
     , SDD_INS_rec8.USRX14
     , SDD_INS_rec8.USRX15
     , SDD_INS_rec8.USRX16
     , SDD_INS_rec8.USRX17
     , SDD_INS_rec8.USRX18
     , SDD_INS_rec8.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_INS_rec8.irid, SDD_INS_rec8.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_INP_rec9 in SDD_INP_cur9 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_INP
    values (
       SDD_INP_rec9.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_INP_rec9.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_INP_rec9.TYPES
     , SDD_INP_rec9.ELEMENT_TYPE_NAME
     , SDD_INP_rec9.DATE_CREATED
     , SDD_INP_rec9.CREATED_BY
     , SDD_INP_rec9.DATE_CHANGED
     , SDD_INP_rec9.CHANGED_BY
     , SDD_INP_rec9.NOTM
     , SDD_INP_rec9.TABLE_PARTITION_REF
     , SDD_INP_rec9.INDEX_STORAGE_REF
     , SDD_INP_rec9.NAME
     , SDD_INP_rec9.SEQUENCE_NUMBER
     , SDD_INP_rec9.VALUE_LESS_THAN
     , SDD_INP_rec9.TABLESPACE_REF
     , SDD_INP_rec9.STORAGE_DEFINITION_REF
     , SDD_INP_rec9.INITIAL_TRANSACTION
     , SDD_INP_rec9.MAXIMUM_TRANSACTION
     , SDD_INP_rec9.PERCENT_FREE
     , SDD_INP_rec9.INDEX_PARTITION_TYPE
     , SDD_INP_rec9.USRX0
     , SDD_INP_rec9.USRX1
     , SDD_INP_rec9.USRX2
     , SDD_INP_rec9.USRX3
     , SDD_INP_rec9.USRX4
     , SDD_INP_rec9.USRX5
     , SDD_INP_rec9.USRX6
     , SDD_INP_rec9.USRX7
     , SDD_INP_rec9.USRX8
     , SDD_INP_rec9.USRX9
     , SDD_INP_rec9.USRX10
     , SDD_INP_rec9.USRX11
     , SDD_INP_rec9.USRX12
     , SDD_INP_rec9.USRX13
     , SDD_INP_rec9.USRX14
     , SDD_INP_rec9.USRX15
     , SDD_INP_rec9.USRX16
     , SDD_INP_rec9.USRX17
     , SDD_INP_rec9.USRX18
     , SDD_INP_rec9.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_INP_rec9.irid, SDD_INP_rec9.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_TBICOL_rec10 in SDD_TBICOL_cur10 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_TBICOL
    values (
       SDD_TBICOL_rec10.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_TBICOL_rec10.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_TBICOL_rec10.TYPES
     , SDD_TBICOL_rec10.ELEMENT_TYPE_NAME
     , SDD_TBICOL_rec10.DATE_CREATED
     , SDD_TBICOL_rec10.CREATED_BY
     , SDD_TBICOL_rec10.DATE_CHANGED
     , SDD_TBICOL_rec10.CHANGED_BY
     , SDD_TBICOL_rec10.NOTM
     , SDD_TBICOL_rec10.TABLE_IMPLEMENTATION_REF
     , SDD_TBICOL_rec10.INDEX_STORAGE_REF
     , SDD_TBICOL_rec10.COLUMN_REF
     , SDD_TBICOL_rec10.SEQUENCE_NUMBER
     , SDD_TBICOL_rec10.PARTITION_KEY_FOR
     , SDD_TBICOL_rec10.USRX0
     , SDD_TBICOL_rec10.USRX1
     , SDD_TBICOL_rec10.USRX2
     , SDD_TBICOL_rec10.USRX3
     , SDD_TBICOL_rec10.USRX4
     , SDD_TBICOL_rec10.USRX5
     , SDD_TBICOL_rec10.USRX6
     , SDD_TBICOL_rec10.USRX7
     , SDD_TBICOL_rec10.USRX8
     , SDD_TBICOL_rec10.USRX9
     , SDD_TBICOL_rec10.USRX10
     , SDD_TBICOL_rec10.USRX11
     , SDD_TBICOL_rec10.USRX12
     , SDD_TBICOL_rec10.USRX13
     , SDD_TBICOL_rec10.USRX14
     , SDD_TBICOL_rec10.USRX15
     , SDD_TBICOL_rec10.USRX16
     , SDD_TBICOL_rec10.USRX17
     , SDD_TBICOL_rec10.USRX18
     , SDD_TBICOL_rec10.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_TBICOL_rec10.irid, SDD_TBICOL_rec10.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_TBP_rec11 in SDD_TBP_cur11 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_TBP
    values (
       SDD_TBP_rec11.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_TBP_rec11.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_TBP_rec11.TYPES
     , SDD_TBP_rec11.ELEMENT_TYPE_NAME
     , SDD_TBP_rec11.DATE_CREATED
     , SDD_TBP_rec11.CREATED_BY
     , SDD_TBP_rec11.DATE_CHANGED
     , SDD_TBP_rec11.CHANGED_BY
     , SDD_TBP_rec11.NOTM
     , SDD_TBP_rec11.TABLE_IMPLEMENTATION_REF
     , SDD_TBP_rec11.NAME
     , SDD_TBP_rec11.SEQUENCE_NUMBER
     , SDD_TBP_rec11.VALUE_LESS_THAN
     , SDD_TBP_rec11.TABLESPACE_REF
     , SDD_TBP_rec11.STORAGE_DEFINITION_REF
     , SDD_TBP_rec11.INITIAL_TRANSACTION
     , SDD_TBP_rec11.MAXIMUM_TRANSACTION
     , SDD_TBP_rec11.PERCENT_FREE
     , SDD_TBP_rec11.PERCENT_USED
     , SDD_TBP_rec11.USRX0
     , SDD_TBP_rec11.USRX1
     , SDD_TBP_rec11.USRX2
     , SDD_TBP_rec11.USRX3
     , SDD_TBP_rec11.USRX4
     , SDD_TBP_rec11.USRX5
     , SDD_TBP_rec11.USRX6
     , SDD_TBP_rec11.USRX7
     , SDD_TBP_rec11.USRX8
     , SDD_TBP_rec11.USRX9
     , SDD_TBP_rec11.USRX10
     , SDD_TBP_rec11.USRX11
     , SDD_TBP_rec11.USRX12
     , SDD_TBP_rec11.USRX13
     , SDD_TBP_rec11.USRX14
     , SDD_TBP_rec11.USRX15
     , SDD_TBP_rec11.USRX16
     , SDD_TBP_rec11.USRX17
     , SDD_TBP_rec11.USRX18
     , SDD_TBP_rec11.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_TBP_rec11.irid, SDD_TBP_rec11.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_SPV_rec12 in SDD_SPV_cur12 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_SPV
    values (
       SDD_SPV_rec12.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_SPV_rec12.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_SPV_rec12.TYPES
     , SDD_SPV_rec12.ELEMENT_TYPE_NAME
     , SDD_SPV_rec12.DATE_CREATED
     , SDD_SPV_rec12.CREATED_BY
     , SDD_SPV_rec12.DATE_CHANGED
     , SDD_SPV_rec12.CHANGED_BY
     , SDD_SPV_rec12.NOTM
     , SDD_SPV_rec12.DATABASE_USER_REF
     , SDD_SPV_rec12.ROLE_REF
     , SDD_SPV_rec12.SYSTEM_PRIVILEGE_NAME
     , SDD_SPV_rec12.GRANT_ACCESS_FLAG
     , SDD_SPV_rec12.REMARK
     , SDD_SPV_rec12.GRANT_OPTION_TO
     , SDD_SPV_rec12.USRX0
     , SDD_SPV_rec12.USRX1
     , SDD_SPV_rec12.USRX2
     , SDD_SPV_rec12.USRX3
     , SDD_SPV_rec12.USRX4
     , SDD_SPV_rec12.USRX5
     , SDD_SPV_rec12.USRX6
     , SDD_SPV_rec12.USRX7
     , SDD_SPV_rec12.USRX8
     , SDD_SPV_rec12.USRX9
     , SDD_SPV_rec12.USRX10
     , SDD_SPV_rec12.USRX11
     , SDD_SPV_rec12.USRX12
     , SDD_SPV_rec12.USRX13
     , SDD_SPV_rec12.USRX14
     , SDD_SPV_rec12.USRX15
     , SDD_SPV_rec12.USRX16
     , SDD_SPV_rec12.USRX17
     , SDD_SPV_rec12.USRX18
     , SDD_SPV_rec12.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_SPV_rec12.irid, SDD_SPV_rec12.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_TSQ_rec13 in SDD_TSQ_cur13 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_TSQ
    values (
       SDD_TSQ_rec13.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_TSQ_rec13.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_TSQ_rec13.TYPES
     , SDD_TSQ_rec13.ELEMENT_TYPE_NAME
     , SDD_TSQ_rec13.DATE_CREATED
     , SDD_TSQ_rec13.CREATED_BY
     , SDD_TSQ_rec13.DATE_CHANGED
     , SDD_TSQ_rec13.CHANGED_BY
     , SDD_TSQ_rec13.NOTM
     , SDD_TSQ_rec13.DATABASE_USER_REF
     , SDD_TSQ_rec13.TABLESPACE_REF
     , SDD_TSQ_rec13.QUOTA
     , SDD_TSQ_rec13.UNITS_OF_QUOTA
     , SDD_TSQ_rec13.REMARK
     , SDD_TSQ_rec13.USRX0
     , SDD_TSQ_rec13.USRX1
     , SDD_TSQ_rec13.USRX2
     , SDD_TSQ_rec13.USRX3
     , SDD_TSQ_rec13.USRX4
     , SDD_TSQ_rec13.USRX5
     , SDD_TSQ_rec13.USRX6
     , SDD_TSQ_rec13.USRX7
     , SDD_TSQ_rec13.USRX8
     , SDD_TSQ_rec13.USRX9
     , SDD_TSQ_rec13.USRX10
     , SDD_TSQ_rec13.USRX11
     , SDD_TSQ_rec13.USRX12
     , SDD_TSQ_rec13.USRX13
     , SDD_TSQ_rec13.USRX14
     , SDD_TSQ_rec13.USRX15
     , SDD_TSQ_rec13.USRX16
     , SDD_TSQ_rec13.USRX17
     , SDD_TSQ_rec13.USRX18
     , SDD_TSQ_rec13.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_TSQ_rec13.irid, SDD_TSQ_rec13.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_DFI_rec14 in SDD_DFI_cur14 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DFI
    values (
       SDD_DFI_rec14.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DFI_rec14.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DFI_rec14.TYPES
     , SDD_DFI_rec14.ELEMENT_TYPE_NAME
     , SDD_DFI_rec14.DATE_CREATED
     , SDD_DFI_rec14.CREATED_BY
     , SDD_DFI_rec14.DATE_CHANGED
     , SDD_DFI_rec14.CHANGED_BY
     , SDD_DFI_rec14.NOTM
     , SDD_DFI_rec14.ORACLE_DATABASE_REF
     , SDD_DFI_rec14.TABLESPACE_REF
     , SDD_DFI_rec14.NAME
     , SDD_DFI_rec14.FULL_PATHNAME
     , SDD_DFI_rec14.REUSE_FLAG
     , SDD_DFI_rec14.GROUP_NUMBER
     , SDD_DFI_rec14.FILE_SIZE
     , SDD_DFI_rec14.FILE_SIZE_UNIT
     , SDD_DFI_rec14.MAXIMUM_SIZE
     , SDD_DFI_rec14.MAXIMUM_SIZE_UNITS
     , SDD_DFI_rec14.AUTOEXTEND_FLAG
     , SDD_DFI_rec14.NEXT_AUTOEXTEND_AMOUNT
     , SDD_DFI_rec14.NEXT_AUTOEXTEND_UNITS
     , SDD_DFI_rec14.REMARK
     , SDD_DFI_rec14.DATABASE_FILE_TYPE
     , SDD_DFI_rec14.DATAFILE_FOR
     , SDD_DFI_rec14.USRX0
     , SDD_DFI_rec14.USRX1
     , SDD_DFI_rec14.USRX2
     , SDD_DFI_rec14.USRX3
     , SDD_DFI_rec14.USRX4
     , SDD_DFI_rec14.USRX5
     , SDD_DFI_rec14.USRX6
     , SDD_DFI_rec14.USRX7
     , SDD_DFI_rec14.USRX8
     , SDD_DFI_rec14.USRX9
     , SDD_DFI_rec14.USRX10
     , SDD_DFI_rec14.USRX11
     , SDD_DFI_rec14.USRX12
     , SDD_DFI_rec14.USRX13
     , SDD_DFI_rec14.USRX14
     , SDD_DFI_rec14.USRX15
     , SDD_DFI_rec14.USRX16
     , SDD_DFI_rec14.USRX17
     , SDD_DFI_rec14.USRX18
     , SDD_DFI_rec14.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DFI_rec14.irid, SDD_DFI_rec14.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_DIR_rec15 in SDD_DIR_cur15 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DIR
    values (
       SDD_DIR_rec15.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DIR_rec15.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DIR_rec15.TYPES
     , SDD_DIR_rec15.ELEMENT_TYPE_NAME
     , SDD_DIR_rec15.DATE_CREATED
     , SDD_DIR_rec15.CREATED_BY
     , SDD_DIR_rec15.DATE_CHANGED
     , SDD_DIR_rec15.CHANGED_BY
     , SDD_DIR_rec15.NOTM
     , SDD_DIR_rec15.ORACLE_DATABASE_REF
     , SDD_DIR_rec15.NAME
     , SDD_DIR_rec15.PATH
     , SDD_DIR_rec15.COMPLETE_FLAG
     , SDD_DIR_rec15.USRX0
     , SDD_DIR_rec15.USRX1
     , SDD_DIR_rec15.USRX2
     , SDD_DIR_rec15.USRX3
     , SDD_DIR_rec15.USRX4
     , SDD_DIR_rec15.USRX5
     , SDD_DIR_rec15.USRX6
     , SDD_DIR_rec15.USRX7
     , SDD_DIR_rec15.USRX8
     , SDD_DIR_rec15.USRX9
     , SDD_DIR_rec15.USRX10
     , SDD_DIR_rec15.USRX11
     , SDD_DIR_rec15.USRX12
     , SDD_DIR_rec15.USRX13
     , SDD_DIR_rec15.USRX14
     , SDD_DIR_rec15.USRX15
     , SDD_DIR_rec15.USRX16
     , SDD_DIR_rec15.USRX17
     , SDD_DIR_rec15.USRX18
     , SDD_DIR_rec15.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DIR_rec15.irid, SDD_DIR_rec15.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_DPR_rec16 in SDD_DPR_cur16 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DPR
    values (
       SDD_DPR_rec16.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DPR_rec16.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DPR_rec16.TYPES
     , SDD_DPR_rec16.ELEMENT_TYPE_NAME
     , SDD_DPR_rec16.DATE_CREATED
     , SDD_DPR_rec16.CREATED_BY
     , SDD_DPR_rec16.DATE_CHANGED
     , SDD_DPR_rec16.CHANGED_BY
     , SDD_DPR_rec16.NOTM
     , SDD_DPR_rec16.ORACLE_DATABASE_REF
     , SDD_DPR_rec16.NAME
     , SDD_DPR_rec16.SESSIONS_PER_USER
     , SDD_DPR_rec16.CPU_PER_SESSION
     , SDD_DPR_rec16.CPU_PER_CALL
     , SDD_DPR_rec16.CONNECT_TIME
     , SDD_DPR_rec16.IDLE_TIME
     , SDD_DPR_rec16.LOGICAL_READS_PER_SESSION
     , SDD_DPR_rec16.LOGICAL_READS_PER_CALL
     , SDD_DPR_rec16.PRIVATE_SGA
     , SDD_DPR_rec16.PRIVATE_SGA_UNITS
     , SDD_DPR_rec16.COMPOSITE_LIMIT
     , SDD_DPR_rec16.FAILED_LOGIN_ATTEMPTS
     , SDD_DPR_rec16.ACCOUNT_LOCK_TIME
     , SDD_DPR_rec16.PASSWORD_LIFETIME
     , SDD_DPR_rec16.PASSWORD_REUSE_TIME
     , SDD_DPR_rec16.PASSWORD_REUSE_MAX
     , SDD_DPR_rec16.PASSWORD_VERIFY_FUNCTION
     , SDD_DPR_rec16.PASSWORD_GRACE_TIME
     , SDD_DPR_rec16.USRX0
     , SDD_DPR_rec16.USRX1
     , SDD_DPR_rec16.USRX2
     , SDD_DPR_rec16.USRX3
     , SDD_DPR_rec16.USRX4
     , SDD_DPR_rec16.USRX5
     , SDD_DPR_rec16.USRX6
     , SDD_DPR_rec16.USRX7
     , SDD_DPR_rec16.USRX8
     , SDD_DPR_rec16.USRX9
     , SDD_DPR_rec16.USRX10
     , SDD_DPR_rec16.USRX11
     , SDD_DPR_rec16.USRX12
     , SDD_DPR_rec16.USRX13
     , SDD_DPR_rec16.USRX14
     , SDD_DPR_rec16.USRX15
     , SDD_DPR_rec16.USRX16
     , SDD_DPR_rec16.USRX17
     , SDD_DPR_rec16.USRX18
     , SDD_DPR_rec16.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DPR_rec16.irid, SDD_DPR_rec16.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_GRP_rec17 in SDD_GRP_cur17 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_GRP
    values (
       SDD_GRP_rec17.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_GRP_rec17.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_GRP_rec17.TYPES
     , SDD_GRP_rec17.ELEMENT_TYPE_NAME
     , SDD_GRP_rec17.DATE_CREATED
     , SDD_GRP_rec17.CREATED_BY
     , SDD_GRP_rec17.DATE_CHANGED
     , SDD_GRP_rec17.CHANGED_BY
     , SDD_GRP_rec17.NOTM
     , SDD_GRP_rec17.ORACLE_DATABASE_REF
     , SDD_GRP_rec17.NAME
     , SDD_GRP_rec17.INITIAL_PASSWORD
     , SDD_GRP_rec17.COMPLETE_FLAG
     , SDD_GRP_rec17.REMARK
     , SDD_GRP_rec17.SYSTEM_ELEMENT_FLAG
     , SDD_GRP_rec17.USRX0
     , SDD_GRP_rec17.USRX1
     , SDD_GRP_rec17.USRX2
     , SDD_GRP_rec17.USRX3
     , SDD_GRP_rec17.USRX4
     , SDD_GRP_rec17.USRX5
     , SDD_GRP_rec17.USRX6
     , SDD_GRP_rec17.USRX7
     , SDD_GRP_rec17.USRX8
     , SDD_GRP_rec17.USRX9
     , SDD_GRP_rec17.USRX10
     , SDD_GRP_rec17.USRX11
     , SDD_GRP_rec17.USRX12
     , SDD_GRP_rec17.USRX13
     , SDD_GRP_rec17.USRX14
     , SDD_GRP_rec17.USRX15
     , SDD_GRP_rec17.USRX16
     , SDD_GRP_rec17.USRX17
     , SDD_GRP_rec17.USRX18
     , SDD_GRP_rec17.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_GRP_rec17.irid, SDD_GRP_rec17.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_GRPGRP_rec18 in SDD_GRPGRP_cur18 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_GRPGRP
    values (
       SDD_GRPGRP_rec18.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_GRPGRP_rec18.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_GRPGRP_rec18.TYPES
     , SDD_GRPGRP_rec18.ELEMENT_TYPE_NAME
     , SDD_GRPGRP_rec18.DATE_CREATED
     , SDD_GRPGRP_rec18.CREATED_BY
     , SDD_GRPGRP_rec18.DATE_CHANGED
     , SDD_GRPGRP_rec18.CHANGED_BY
     , SDD_GRPGRP_rec18.NOTM
     , SDD_GRPGRP_rec18.GRANTEE_ROLE_REF
     , SDD_GRPGRP_rec18.GRANTOR_ROLE_REF
     , SDD_GRPGRP_rec18.WITH_GRANT_OPT_IND
     , SDD_GRPGRP_rec18.USRX0
     , SDD_GRPGRP_rec18.USRX1
     , SDD_GRPGRP_rec18.USRX2
     , SDD_GRPGRP_rec18.USRX3
     , SDD_GRPGRP_rec18.USRX4
     , SDD_GRPGRP_rec18.USRX5
     , SDD_GRPGRP_rec18.USRX6
     , SDD_GRPGRP_rec18.USRX7
     , SDD_GRPGRP_rec18.USRX8
     , SDD_GRPGRP_rec18.USRX9
     , SDD_GRPGRP_rec18.USRX10
     , SDD_GRPGRP_rec18.USRX11
     , SDD_GRPGRP_rec18.USRX12
     , SDD_GRPGRP_rec18.USRX13
     , SDD_GRPGRP_rec18.USRX14
     , SDD_GRPGRP_rec18.USRX15
     , SDD_GRPGRP_rec18.USRX16
     , SDD_GRPGRP_rec18.USRX17
     , SDD_GRPGRP_rec18.USRX18
     , SDD_GRPGRP_rec18.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_GRPGRP_rec18.irid, SDD_GRPGRP_rec18.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_GRPMOD_rec19 in SDD_GRPMOD_cur19 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_GRPMOD
    values (
       SDD_GRPMOD_rec19.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_GRPMOD_rec19.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_GRPMOD_rec19.TYPES
     , SDD_GRPMOD_rec19.ELEMENT_TYPE_NAME
     , SDD_GRPMOD_rec19.DATE_CREATED
     , SDD_GRPMOD_rec19.CREATED_BY
     , SDD_GRPMOD_rec19.DATE_CHANGED
     , SDD_GRPMOD_rec19.CHANGED_BY
     , SDD_GRPMOD_rec19.NOTM
     , SDD_GRPMOD_rec19.ROLE_REF
     , SDD_GRPMOD_rec19.GENERAL_MODULE_REF
     , SDD_GRPMOD_rec19.WITH_GRANT_OPT_IND
     , SDD_GRPMOD_rec19.USRX0
     , SDD_GRPMOD_rec19.USRX1
     , SDD_GRPMOD_rec19.USRX2
     , SDD_GRPMOD_rec19.USRX3
     , SDD_GRPMOD_rec19.USRX4
     , SDD_GRPMOD_rec19.USRX5
     , SDD_GRPMOD_rec19.USRX6
     , SDD_GRPMOD_rec19.USRX7
     , SDD_GRPMOD_rec19.USRX8
     , SDD_GRPMOD_rec19.USRX9
     , SDD_GRPMOD_rec19.USRX10
     , SDD_GRPMOD_rec19.USRX11
     , SDD_GRPMOD_rec19.USRX12
     , SDD_GRPMOD_rec19.USRX13
     , SDD_GRPMOD_rec19.USRX14
     , SDD_GRPMOD_rec19.USRX15
     , SDD_GRPMOD_rec19.USRX16
     , SDD_GRPMOD_rec19.USRX17
     , SDD_GRPMOD_rec19.USRX18
     , SDD_GRPMOD_rec19.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_GRPMOD_rec19.irid, SDD_GRPMOD_rec19.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_LST_rec20 in SDD_LST_cur20 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_LST
    values (
       SDD_LST_rec20.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_LST_rec20.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_LST_rec20.TYPES
     , SDD_LST_rec20.ELEMENT_TYPE_NAME
     , SDD_LST_rec20.DATE_CREATED
     , SDD_LST_rec20.CREATED_BY
     , SDD_LST_rec20.DATE_CHANGED
     , SDD_LST_rec20.CHANGED_BY
     , SDD_LST_rec20.NOTM
     , SDD_LST_rec20.ORACLE_DATABASE_REF
     , SDD_LST_rec20.NAME
     , SDD_LST_rec20.TABLESPACE_REF
     , SDD_LST_rec20.STORAGE_DEFINITION_REF
     , SDD_LST_rec20.CHUNK
     , SDD_LST_rec20.CHUNK_UNIT
     , SDD_LST_rec20.PCTVERSION
     , SDD_LST_rec20.CACHE_FLAG
     , SDD_LST_rec20.LOGGING_FLAG
     , SDD_LST_rec20.INDEX_TABLESPACE_REF
     , SDD_LST_rec20.INDEX_STORAGE_DEFN_REF
     , SDD_LST_rec20.INDEX_INITIAL_TRANSACTION
     , SDD_LST_rec20.INDEX_MAXIMUM_TRANSACTION
     , SDD_LST_rec20.USRX0
     , SDD_LST_rec20.USRX1
     , SDD_LST_rec20.USRX2
     , SDD_LST_rec20.USRX3
     , SDD_LST_rec20.USRX4
     , SDD_LST_rec20.USRX5
     , SDD_LST_rec20.USRX6
     , SDD_LST_rec20.USRX7
     , SDD_LST_rec20.USRX8
     , SDD_LST_rec20.USRX9
     , SDD_LST_rec20.USRX10
     , SDD_LST_rec20.USRX11
     , SDD_LST_rec20.USRX12
     , SDD_LST_rec20.USRX13
     , SDD_LST_rec20.USRX14
     , SDD_LST_rec20.USRX15
     , SDD_LST_rec20.USRX16
     , SDD_LST_rec20.USRX17
     , SDD_LST_rec20.USRX18
     , SDD_LST_rec20.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_LST_rec20.irid, SDD_LST_rec20.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_ODBODB_rec21 in SDD_ODBODB_cur21 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ODBODB
    values (
       SDD_ODBODB_rec21.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ODBODB_rec21.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ODBODB_rec21.TYPES
     , SDD_ODBODB_rec21.ELEMENT_TYPE_NAME
     , SDD_ODBODB_rec21.DATE_CREATED
     , SDD_ODBODB_rec21.CREATED_BY
     , SDD_ODBODB_rec21.DATE_CHANGED
     , SDD_ODBODB_rec21.CHANGED_BY
     , SDD_ODBODB_rec21.NOTM
     , SDD_ODBODB_rec21.DATABASE_REF_FROM
     , SDD_ODBODB_rec21.DATABASE_REF_TO
     , SDD_ODBODB_rec21.USRX0
     , SDD_ODBODB_rec21.USRX1
     , SDD_ODBODB_rec21.USRX2
     , SDD_ODBODB_rec21.USRX3
     , SDD_ODBODB_rec21.USRX4
     , SDD_ODBODB_rec21.USRX5
     , SDD_ODBODB_rec21.USRX6
     , SDD_ODBODB_rec21.USRX7
     , SDD_ODBODB_rec21.USRX8
     , SDD_ODBODB_rec21.USRX9
     , SDD_ODBODB_rec21.USRX10
     , SDD_ODBODB_rec21.USRX11
     , SDD_ODBODB_rec21.USRX12
     , SDD_ODBODB_rec21.USRX13
     , SDD_ODBODB_rec21.USRX14
     , SDD_ODBODB_rec21.USRX15
     , SDD_ODBODB_rec21.USRX16
     , SDD_ODBODB_rec21.USRX17
     , SDD_ODBODB_rec21.USRX18
     , SDD_ODBODB_rec21.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ODBODB_rec21.irid, SDD_ODBODB_rec21.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_ORS_rec22 in SDD_ORS_cur22 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ORS
    values (
       SDD_ORS_rec22.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ORS_rec22.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ORS_rec22.TYPES
     , SDD_ORS_rec22.ELEMENT_TYPE_NAME
     , SDD_ORS_rec22.DATE_CREATED
     , SDD_ORS_rec22.CREATED_BY
     , SDD_ORS_rec22.DATE_CHANGED
     , SDD_ORS_rec22.CHANGED_BY
     , SDD_ORS_rec22.NOTM
     , SDD_ORS_rec22.ORACLE_DATABASE_REF
     , SDD_ORS_rec22.NAME
     , SDD_ORS_rec22.PUBLIC_FLAG
     , SDD_ORS_rec22.COMPLETE_FLAG
     , SDD_ORS_rec22.TABLESPACE_REF
     , SDD_ORS_rec22.STORAGE_DEFINITION_REF
     , SDD_ORS_rec22.OPTIMAL_SIZE
     , SDD_ORS_rec22.OPTIMAL_SIZE_UNIT
     , SDD_ORS_rec22.REMARK
     , SDD_ORS_rec22.USRX0
     , SDD_ORS_rec22.USRX1
     , SDD_ORS_rec22.USRX2
     , SDD_ORS_rec22.USRX3
     , SDD_ORS_rec22.USRX4
     , SDD_ORS_rec22.USRX5
     , SDD_ORS_rec22.USRX6
     , SDD_ORS_rec22.USRX7
     , SDD_ORS_rec22.USRX8
     , SDD_ORS_rec22.USRX9
     , SDD_ORS_rec22.USRX10
     , SDD_ORS_rec22.USRX11
     , SDD_ORS_rec22.USRX12
     , SDD_ORS_rec22.USRX13
     , SDD_ORS_rec22.USRX14
     , SDD_ORS_rec22.USRX15
     , SDD_ORS_rec22.USRX16
     , SDD_ORS_rec22.USRX17
     , SDD_ORS_rec22.USRX18
     , SDD_ORS_rec22.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ORS_rec22.irid, SDD_ORS_rec22.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_OTB_rec23 in SDD_OTB_cur23 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_OTB
    values (
       SDD_OTB_rec23.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_OTB_rec23.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_OTB_rec23.TYPES
     , SDD_OTB_rec23.ELEMENT_TYPE_NAME
     , SDD_OTB_rec23.DATE_CREATED
     , SDD_OTB_rec23.CREATED_BY
     , SDD_OTB_rec23.DATE_CHANGED
     , SDD_OTB_rec23.CHANGED_BY
     , SDD_OTB_rec23.NOTM
     , SDD_OTB_rec23.DATABASE_REF
     , SDD_OTB_rec23.NAME
     , SDD_OTB_rec23.COMPLETE_FLAG
     , SDD_OTB_rec23.ONLINE_FLAG
     , SDD_OTB_rec23.READ_ONLY
     , SDD_OTB_rec23.TEMPORARY_FLAG
     , SDD_OTB_rec23.STORAGE_DEFINITION_REF
     , SDD_OTB_rec23.REMARK
     , SDD_OTB_rec23.USRX0
     , SDD_OTB_rec23.USRX1
     , SDD_OTB_rec23.USRX2
     , SDD_OTB_rec23.USRX3
     , SDD_OTB_rec23.USRX4
     , SDD_OTB_rec23.USRX5
     , SDD_OTB_rec23.USRX6
     , SDD_OTB_rec23.USRX7
     , SDD_OTB_rec23.USRX8
     , SDD_OTB_rec23.USRX9
     , SDD_OTB_rec23.USRX10
     , SDD_OTB_rec23.USRX11
     , SDD_OTB_rec23.USRX12
     , SDD_OTB_rec23.USRX13
     , SDD_OTB_rec23.USRX14
     , SDD_OTB_rec23.USRX15
     , SDD_OTB_rec23.USRX16
     , SDD_OTB_rec23.USRX17
     , SDD_OTB_rec23.USRX18
     , SDD_OTB_rec23.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_OTB_rec23.irid, SDD_OTB_rec23.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_QUI_rec24 in SDD_QUI_cur24 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_QUI
    values (
       SDD_QUI_rec24.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_QUI_rec24.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_QUI_rec24.TYPES
     , SDD_QUI_rec24.ELEMENT_TYPE_NAME
     , SDD_QUI_rec24.DATE_CREATED
     , SDD_QUI_rec24.CREATED_BY
     , SDD_QUI_rec24.DATE_CHANGED
     , SDD_QUI_rec24.CHANGED_BY
     , SDD_QUI_rec24.NOTM
     , SDD_QUI_rec24.ORACLE_DATABASE_REF
     , SDD_QUI_rec24.NON_PERSISTENT_QUEUE_REF
     , SDD_QUI_rec24.PERSISTENT_QUEUE_REF
     , SDD_QUI_rec24.COMPLETE_FLAG
     , SDD_QUI_rec24.QUEUE_TABLE_DBU_REF
     , SDD_QUI_rec24.MAX_RETRIES
     , SDD_QUI_rec24.RETRY_DELAY
     , SDD_QUI_rec24.RETENTION_TIME
     , SDD_QUI_rec24.INFINITE_FLAG
     , SDD_QUI_rec24.QUEUE_IMPLEMENTATION_SUBTYPE
     , SDD_QUI_rec24.USRX0
     , SDD_QUI_rec24.USRX1
     , SDD_QUI_rec24.USRX2
     , SDD_QUI_rec24.USRX3
     , SDD_QUI_rec24.USRX4
     , SDD_QUI_rec24.USRX5
     , SDD_QUI_rec24.USRX6
     , SDD_QUI_rec24.USRX7
     , SDD_QUI_rec24.USRX8
     , SDD_QUI_rec24.USRX9
     , SDD_QUI_rec24.USRX10
     , SDD_QUI_rec24.USRX11
     , SDD_QUI_rec24.USRX12
     , SDD_QUI_rec24.USRX13
     , SDD_QUI_rec24.USRX14
     , SDD_QUI_rec24.USRX15
     , SDD_QUI_rec24.USRX16
     , SDD_QUI_rec24.USRX17
     , SDD_QUI_rec24.USRX18
     , SDD_QUI_rec24.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_QUI_rec24.irid, SDD_QUI_rec24.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_QSU_rec25 in SDD_QSU_cur25 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_QSU
    values (
       SDD_QSU_rec25.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_QSU_rec25.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_QSU_rec25.TYPES
     , SDD_QSU_rec25.ELEMENT_TYPE_NAME
     , SDD_QSU_rec25.DATE_CREATED
     , SDD_QSU_rec25.CREATED_BY
     , SDD_QSU_rec25.DATE_CHANGED
     , SDD_QSU_rec25.CHANGED_BY
     , SDD_QSU_rec25.NOTM
     , SDD_QSU_rec25.QUEUE_IMPLEMENTATION_REF
     , SDD_QSU_rec25.NAME
     , SDD_QSU_rec25.ADDRESS
     , SDD_QSU_rec25.PROTOCOL
     , SDD_QSU_rec25.RULE
     , SDD_QSU_rec25.USRX0
     , SDD_QSU_rec25.USRX1
     , SDD_QSU_rec25.USRX2
     , SDD_QSU_rec25.USRX3
     , SDD_QSU_rec25.USRX4
     , SDD_QSU_rec25.USRX5
     , SDD_QSU_rec25.USRX6
     , SDD_QSU_rec25.USRX7
     , SDD_QSU_rec25.USRX8
     , SDD_QSU_rec25.USRX9
     , SDD_QSU_rec25.USRX10
     , SDD_QSU_rec25.USRX11
     , SDD_QSU_rec25.USRX12
     , SDD_QSU_rec25.USRX13
     , SDD_QSU_rec25.USRX14
     , SDD_QSU_rec25.USRX15
     , SDD_QSU_rec25.USRX16
     , SDD_QSU_rec25.USRX17
     , SDD_QSU_rec25.USRX18
     , SDD_QSU_rec25.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_QSU_rec25.irid, SDD_QSU_rec25.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_RPG_rec26 in SDD_RPG_cur26 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_RPG
    values (
       SDD_RPG_rec26.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_RPG_rec26.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_RPG_rec26.TYPES
     , SDD_RPG_rec26.ELEMENT_TYPE_NAME
     , SDD_RPG_rec26.DATE_CREATED
     , SDD_RPG_rec26.CREATED_BY
     , SDD_RPG_rec26.DATE_CHANGED
     , SDD_RPG_rec26.CHANGED_BY
     , SDD_RPG_rec26.NOTM
     , SDD_RPG_rec26.ORACLE_DATABASE_REF
     , SDD_RPG_rec26.NAME
     , SDD_RPG_rec26.REMARK
     , SDD_RPG_rec26.USRX0
     , SDD_RPG_rec26.USRX1
     , SDD_RPG_rec26.USRX2
     , SDD_RPG_rec26.USRX3
     , SDD_RPG_rec26.USRX4
     , SDD_RPG_rec26.USRX5
     , SDD_RPG_rec26.USRX6
     , SDD_RPG_rec26.USRX7
     , SDD_RPG_rec26.USRX8
     , SDD_RPG_rec26.USRX9
     , SDD_RPG_rec26.USRX10
     , SDD_RPG_rec26.USRX11
     , SDD_RPG_rec26.USRX12
     , SDD_RPG_rec26.USRX13
     , SDD_RPG_rec26.USRX14
     , SDD_RPG_rec26.USRX15
     , SDD_RPG_rec26.USRX16
     , SDD_RPG_rec26.USRX17
     , SDD_RPG_rec26.USRX18
     , SDD_RPG_rec26.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_RPG_rec26.irid, SDD_RPG_rec26.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_RGP_rec27 in SDD_RGP_cur27 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_RGP
    values (
       SDD_RGP_rec27.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_RGP_rec27.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_RGP_rec27.TYPES
     , SDD_RGP_rec27.ELEMENT_TYPE_NAME
     , SDD_RGP_rec27.DATE_CREATED
     , SDD_RGP_rec27.CREATED_BY
     , SDD_RGP_rec27.DATE_CHANGED
     , SDD_RGP_rec27.CHANGED_BY
     , SDD_RGP_rec27.NOTM
     , SDD_RGP_rec27.REPLICATION_GROUP_REF
     , SDD_RGP_rec27.ORACLE_DATABASE_REF
     , SDD_RGP_rec27.PROPAGATION_METHOD
     , SDD_RGP_rec27.SETUP_METHOD
     , SDD_RGP_rec27.USRX0
     , SDD_RGP_rec27.USRX1
     , SDD_RGP_rec27.USRX2
     , SDD_RGP_rec27.USRX3
     , SDD_RGP_rec27.USRX4
     , SDD_RGP_rec27.USRX5
     , SDD_RGP_rec27.USRX6
     , SDD_RGP_rec27.USRX7
     , SDD_RGP_rec27.USRX8
     , SDD_RGP_rec27.USRX9
     , SDD_RGP_rec27.USRX10
     , SDD_RGP_rec27.USRX11
     , SDD_RGP_rec27.USRX12
     , SDD_RGP_rec27.USRX13
     , SDD_RGP_rec27.USRX14
     , SDD_RGP_rec27.USRX15
     , SDD_RGP_rec27.USRX16
     , SDD_RGP_rec27.USRX17
     , SDD_RGP_rec27.USRX18
     , SDD_RGP_rec27.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_RGP_rec27.irid, SDD_RGP_rec27.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_SRG_rec28 in SDD_SRG_cur28 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_SRG
    values (
       SDD_SRG_rec28.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_SRG_rec28.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_SRG_rec28.TYPES
     , SDD_SRG_rec28.ELEMENT_TYPE_NAME
     , SDD_SRG_rec28.DATE_CREATED
     , SDD_SRG_rec28.CREATED_BY
     , SDD_SRG_rec28.DATE_CHANGED
     , SDD_SRG_rec28.CHANGED_BY
     , SDD_SRG_rec28.NOTM
     , SDD_SRG_rec28.ORACLE_DATABASE_REF
     , SDD_SRG_rec28.NAME
     , SDD_SRG_rec28.NEXT_DATE
     , SDD_SRG_rec28.INTERVAL
     , SDD_SRG_rec28.IMPLICIT_DESTROY
     , SDD_SRG_rec28.ROLLBACK_SEGMENT_REF
     , SDD_SRG_rec28.PUSH_DEFERRED_RPC
     , SDD_SRG_rec28.REFRESH_AFTER_ERRORS
     , SDD_SRG_rec28.USRX0
     , SDD_SRG_rec28.USRX1
     , SDD_SRG_rec28.USRX2
     , SDD_SRG_rec28.USRX3
     , SDD_SRG_rec28.USRX4
     , SDD_SRG_rec28.USRX5
     , SDD_SRG_rec28.USRX6
     , SDD_SRG_rec28.USRX7
     , SDD_SRG_rec28.USRX8
     , SDD_SRG_rec28.USRX9
     , SDD_SRG_rec28.USRX10
     , SDD_SRG_rec28.USRX11
     , SDD_SRG_rec28.USRX12
     , SDD_SRG_rec28.USRX13
     , SDD_SRG_rec28.USRX14
     , SDD_SRG_rec28.USRX15
     , SDD_SRG_rec28.USRX16
     , SDD_SRG_rec28.USRX17
     , SDD_SRG_rec28.USRX18
     , SDD_SRG_rec28.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_SRG_rec28.irid, SDD_SRG_rec28.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  jr_reg_ver.vercopy_dependent_objects(SDD_ODB_ver.ivid, new_ivid);
  return new_ivid;
end SDD_ODB_ver;
/
create or replace function PK_SDD_ODB (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_ODB the_tab_new, SDD_ODB the_tab_old
  where  the_tab_new.ivid = PK_SDD_ODB.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_ODB.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_ODB;
/
create or replace function FK_ODB_TO_E20 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.NODE_REF ref_value
  from   i$SDD_ODB the_tab
  where  the_tab.ivid = FK_ODB_TO_E20.object_ivid
  and    the_tab.NODE_REF is not null
  and    not exists (
             select null
             from   SDD_E20 foreign_tab
             where  the_tab.NODE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4961, action);
  end loop;
  return is_ok;
end FK_ODB_TO_E20;
/
create or replace function PK_SDD_ODBODB (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_ODBODB the_tab_new, SDD_ODBODB the_tab_old
  where  the_tab_new.ivid = PK_SDD_ODBODB.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_ODBODB.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_ODBODB;
/
create or replace function FK_ODBODB_TO_ORC2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.DATABASE_REF_TO ref_value
  from   i$SDD_ODBODB the_tab
  where  the_tab.ivid = FK_ODBODB_TO_ORC2.object_ivid
  and    the_tab.DATABASE_REF_TO is not null
  and    not exists (
             select null
             from   SDD_ODB foreign_tab
             where  the_tab.DATABASE_REF_TO = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4927, action);
  end loop;
  return is_ok;
end FK_ODBODB_TO_ORC2;
/
create or replace function PK_SDD_OKY (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_OKY the_tab_new, SDD_OKY the_tab_old
  where  the_tab_new.ivid = PK_SDD_OKY.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_OKY.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_OKY;
/
create or replace function FK_OKY_TO_COL (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.COLUMN_REF ref_value
  from   i$SDD_OKY the_tab
  where  the_tab.ivid = FK_OKY_TO_COL.object_ivid
  and    the_tab.COLUMN_REF is not null
  and    not exists (
             select null
             from   SDD_COL foreign_tab
             where  the_tab.COLUMN_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5014, action);
  end loop;
  return is_ok;
end FK_OKY_TO_COL;
/
create or replace function FK_OKY_TO_COL2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.FOREIGN_COLUMN_REF ref_value
  from   i$SDD_OKY the_tab
  where  the_tab.ivid = FK_OKY_TO_COL2.object_ivid
  and    the_tab.FOREIGN_COLUMN_REF is not null
  and    not exists (
             select null
             from   SDD_COL foreign_tab
             where  the_tab.FOREIGN_COLUMN_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5014, action);
  end loop;
  return is_ok;
end FK_OKY_TO_COL2;
/
create or replace function FK_OKY_TO_COL3 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.FOREIGN_COLUMN_REF2 ref_value
  from   i$SDD_OKY the_tab
  where  the_tab.ivid = FK_OKY_TO_COL3.object_ivid
  and    the_tab.FOREIGN_COLUMN_REF2 is not null
  and    not exists (
             select null
             from   SDD_COL foreign_tab
             where  the_tab.FOREIGN_COLUMN_REF2 = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5014, action);
  end loop;
  return is_ok;
end FK_OKY_TO_COL3;
/
create or replace function FK_OKY_TO_CQA (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.CQA_REF ref_value
  from   i$SDD_OKY the_tab
  where  the_tab.ivid = FK_OKY_TO_CQA.object_ivid
  and    the_tab.CQA_REF is not null
  and    not exists (
             select null
             from   SDD_CQA foreign_tab
             where  the_tab.CQA_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4856, action);
  end loop;
  return is_ok;
end FK_OKY_TO_CQA;
/
create or replace function FK_OKY_TO_CQA2 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.FOREIGN_CQA_REF ref_value
  from   i$SDD_OKY the_tab
  where  the_tab.ivid = FK_OKY_TO_CQA2.object_ivid
  and    the_tab.FOREIGN_CQA_REF is not null
  and    not exists (
             select null
             from   SDD_CQA foreign_tab
             where  the_tab.FOREIGN_CQA_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4856, action);
  end loop;
  return is_ok;
end FK_OKY_TO_CQA2;
/
create or replace function FK_OKY_TO_CQA3 (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.FOREIGN_CQA_REF2 ref_value
  from   i$SDD_OKY the_tab
  where  the_tab.ivid = FK_OKY_TO_CQA3.object_ivid
  and    the_tab.FOREIGN_CQA_REF2 is not null
  and    not exists (
             select null
             from   SDD_CQA foreign_tab
             where  the_tab.FOREIGN_CQA_REF2 = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4856, action);
  end loop;
  return is_ok;
end FK_OKY_TO_CQA3;
/
create or replace function FK_ORG_TO_ORG_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_ORG child_tab
  where  child_tab.ORGANIZATION_UNIT_REF=FK_ORG_TO_ORG_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_ORG child_tab, i$sdd_object_versions o
    where  child_tab.ORGANIZATION_UNIT_REF=FK_ORG_TO_ORG_d.IRID
    and    child_tab.ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_ORG_TO_ORG_d;
/
create or replace function SDD_ORG_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_ORG_cur is
    select *
    from   i$SDD_ORG the_tab
    where  the_tab.irid=SDD_ORG_ver.irid
    and    the_tab.ivid=SDD_ORG_ver.ivid;
  SDD_ORG_rec SDD_ORG_cur%ROWTYPE;
  cursor SDD_ACRORG_cur1 is
    select *
    from i$SDD_ACRORG the_tab
    where the_tab.parent_ivid=SDD_ORG_ver.ivid;
  cursor SDD_ORGPER_cur2 is
    select *
    from i$SDD_ORGPER the_tab
    where the_tab.parent_ivid=SDD_ORG_ver.ivid;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_ORG_cur;
  fetch SDD_ORG_cur into SDD_ORG_rec;
  close SDD_ORG_cur;
  insert into i$SDD_ORG
  values (
    SDD_ORG_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_ORG_rec.TYPES
   ,SDD_ORG_rec.ELEMENT_TYPE_NAME
   ,SDD_ORG_rec.DATE_CREATED
   ,SDD_ORG_rec.CREATED_BY
   ,SDD_ORG_rec.DATE_CHANGED
   ,SDD_ORG_rec.CHANGED_BY
   ,SDD_ORG_rec.NOTM
   ,SDD_ORG_rec.NAME
   ,SDD_ORG_rec.TYPE
   ,SDD_ORG_rec.ORGANIZATION_UNIT_REF
   ,SDD_ORG_rec.HEADCOUNT
   ,SDD_ORG_rec.VIRTUAL_FLAG
   ,SDD_ORG_rec.EXTERNAL_FLAG
   ,SDD_ORG_rec.ICON_FILE_REF
   ,SDD_ORG_rec.EMAIL_ADDRESS
   ,SDD_ORG_rec.SYSTEM_ELEMENT_FLAG
  );
  jr_reg_ver.vercopy_dependencies(SDD_ORG_ver.irid, SDD_ORG_ver.ivid, new_ivid, null, copy_dependencies);
  for SDD_ACRORG_rec1 in SDD_ACRORG_cur1 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ACRORG
    values (
       SDD_ACRORG_rec1.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ACRORG_rec1.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ACRORG_rec1.TYPES
     , SDD_ACRORG_rec1.ELEMENT_TYPE_NAME
     , SDD_ACRORG_rec1.DATE_CREATED
     , SDD_ACRORG_rec1.CREATED_BY
     , SDD_ACRORG_rec1.DATE_CHANGED
     , SDD_ACRORG_rec1.CHANGED_BY
     , SDD_ACRORG_rec1.NOTM
     , SDD_ACRORG_rec1.ORGANIZATION_UNIT_REF
     , SDD_ACRORG_rec1.ACTOR_REF
    );
  jr_reg_ver.vercopy_dependencies(SDD_ACRORG_rec1.irid, SDD_ACRORG_rec1.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_ORGPER_rec2 in SDD_ORGPER_cur2 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ORGPER
    values (
       SDD_ORGPER_rec2.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ORGPER_rec2.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ORGPER_rec2.TYPES
     , SDD_ORGPER_rec2.ELEMENT_TYPE_NAME
     , SDD_ORGPER_rec2.DATE_CREATED
     , SDD_ORGPER_rec2.CREATED_BY
     , SDD_ORGPER_rec2.DATE_CHANGED
     , SDD_ORGPER_rec2.CHANGED_BY
     , SDD_ORGPER_rec2.NOTM
     , SDD_ORGPER_rec2.ORGANIZATION_UNIT_REF
     , SDD_ORGPER_rec2.PERSON_REF
    );
  jr_reg_ver.vercopy_dependencies(SDD_ORGPER_rec2.irid, SDD_ORGPER_rec2.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  jr_reg_ver.vercopy_dependent_objects(SDD_ORG_ver.ivid, new_ivid);
  return new_ivid;
end SDD_ORG_ver;
/
create or replace function PK_SDD_ORG (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_ORG the_tab_new, SDD_ORG the_tab_old
  where  the_tab_new.ivid = PK_SDD_ORG.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_ORG.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_ORG;
/
create or replace function FK_ORG_TO_FILES (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ICON_FILE_REF ref_value
  from   i$SDD_ORG the_tab
  where  the_tab.ivid = FK_ORG_TO_FILES.object_ivid
  and    the_tab.ICON_FILE_REF is not null
  and    not exists (
             select null
             from   SDD_FILES foreign_tab
             where  the_tab.ICON_FILE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4819, action);
  end loop;
  return is_ok;
end FK_ORG_TO_FILES;
/
create or replace function FK_ORG_TO_ORG (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.ORGANIZATION_UNIT_REF ref_value
  from   i$SDD_ORG the_tab
  where  the_tab.ivid = FK_ORG_TO_ORG.object_ivid
  and    the_tab.ORGANIZATION_UNIT_REF is not null
  and    not exists (
             select null
             from   SDD_ORG foreign_tab
             where  the_tab.ORGANIZATION_UNIT_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4837, action);
  end loop;
  return is_ok;
end FK_ORG_TO_ORG;
/
create or replace function PK_SDD_ORGPER (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_ORGPER the_tab_new, SDD_ORGPER the_tab_old
  where  the_tab_new.ivid = PK_SDD_ORGPER.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_ORGPER.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_ORGPER;
/
create or replace function FK_ORGPER_TO_PER (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.PERSON_REF ref_value
  from   i$SDD_ORGPER the_tab
  where  the_tab.ivid = FK_ORGPER_TO_PER.object_ivid
  and    the_tab.PERSON_REF is not null
  and    not exists (
             select null
             from   SDD_PER foreign_tab
             where  the_tab.PERSON_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 4835, action);
  end loop;
  return is_ok;
end FK_ORGPER_TO_PER;
/
create or replace function PK_SDD_ORS (irid number, ivid number) return boolean as
  cursor bad_cur is
  select null
  from   i$SDD_ORS the_tab_new, SDD_ORS the_tab_old
  where  the_tab_new.ivid = PK_SDD_ORS.ivid
  and    the_tab_new.IRID = the_tab_old.IRID
  and    the_tab_old.ivid != PK_SDD_ORS.ivid;
  dummy number;
begin
  open bad_cur;
  fetch bad_cur into dummy;
  if bad_cur%FOUND then
    close bad_cur;
    return FALSE;
  end if;
  close bad_cur;
  return TRUE;
end PK_SDD_ORS;
/
create or replace function FK_ORS_TO_OSP (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.STORAGE_DEFINITION_REF ref_value
  from   i$SDD_ORS the_tab
  where  the_tab.ivid = FK_ORS_TO_OSP.object_ivid
  and    the_tab.STORAGE_DEFINITION_REF is not null
  and    not exists (
             select null
             from   SDD_OSP foreign_tab
             where  the_tab.STORAGE_DEFINITION_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5000, action);
  end loop;
  return is_ok;
end FK_ORS_TO_OSP;
/
create or replace function FK_ORS_TO_OTB (object_ivid number, object_type_irid number, action varchar2) return boolean as
cursor bad_cur is
  select
    the_tab.TABLESPACE_REF ref_value
  from   i$SDD_ORS the_tab
  where  the_tab.ivid = FK_ORS_TO_OTB.object_ivid
  and    the_tab.TABLESPACE_REF is not null
  and    not exists (
             select null
             from   SDD_OTB foreign_tab
             where  the_tab.TABLESPACE_REF = foreign_tab.IRID
             );
  is_ok boolean := true;
begin
  for ref_rec in bad_cur loop
    is_ok := false;
    jr_error.post_referencing_error(object_ivid, object_type_irid, ref_rec.ref_value
                                   , 5001, action);
  end loop;
  return is_ok;
end FK_ORS_TO_OTB;
/
create or replace function FK_ITM_TO_ORT_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_ITM child_tab
  where  child_tab.ORACLE_TYPE_REF=FK_ITM_TO_ORT_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_ITM child_tab, i$sdd_object_versions o
    where  child_tab.ORACLE_TYPE_REF=FK_ITM_TO_ORT_d.IRID
    and    child_tab.parent_ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_ITM_TO_ORT_d;
/
create or replace function FK_QTD_TO_ORT_d (
el_ivid number
 ,IRID NUMBER
,el_type number
,action varchar2
) return boolean as
cursor bad_cur is
  select child_tab.irid, child_tab.types
  from   SDD_QTD child_tab
  where  child_tab.ORACLE_TYPE_REF=FK_QTD_TO_ORT_d.IRID
  ;
 is_ok boolean:=TRUE;
begin
  if jr_context.constraints=jr_context.CONSTRAINTS_DEFERRED then
    insert into i$sdd_invalid_objects (object_irid, object_ivid, table_irid)
    select o.irid, o.ivid, o.table_irid
    from   SDD_QTD child_tab, i$sdd_object_versions o
    where  child_tab.ORACLE_TYPE_REF=FK_QTD_TO_ORT_d.IRID
    and    child_tab.ivid=o.ivid;
   return TRUE;
  end if;
  for ref in bad_cur loop
   is_ok:=FALSE;
   jr_error.post_ref_error(el_ivid,el_type,ref.irid,ref.types,action);
  end loop;
  return is_ok;
end FK_QTD_TO_ORT_d;
/
create or replace function SDD_ORT_ver (irid number, ivid number, copy_dependencies boolean default true) return number as
  new_ivid           number; -- new ivid of primary object
  new_secondary_ivid number; -- new ivid of secondary objects
  cursor SDD_ORT_cur is
    select *
    from   i$SDD_ORT the_tab
    where  the_tab.irid=SDD_ORT_ver.irid
    and    the_tab.ivid=SDD_ORT_ver.ivid;
  SDD_ORT_rec SDD_ORT_cur%ROWTYPE;
  cursor SDD_COL_cur1 is
    select *
    from i$SDD_COL the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_ATV_cur2 is
    select *
    from i$SDD_ATV the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_MOD_cur3 is
    select *
    from i$SDD_MOD the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_ARG_cur4 is
    select *
    from i$SDD_ARG the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_ARGITE_cur5 is
    select *
    from i$SDD_ARGITE the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_DAT_cur6 is
    select *
    from i$SDD_DAT the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_ITM_cur7 is
    select *
    from i$SDD_ITM the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_DSY_cur8 is
    select *
    from i$SDD_DSY the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_LVI_cur9 is
    select *
    from i$SDD_LVI the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_MCH_cur10 is
    select *
    from i$SDD_MCH the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_MCL_cur11 is
    select *
    from i$SDD_MCL the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_MCN_cur12 is
    select *
    from i$SDD_MCN the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_ACI_cur13 is
    select *
    from i$SDD_ACI the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_MODBUN_cur14 is
    select *
    from i$SDD_MODBUN the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_MODFUN_cur15 is
    select *
    from i$SDD_MODFUN the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_MODMOD_cur16 is
    select *
    from i$SDD_MODMOD the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_PVL_cur17 is
    select *
    from i$SDD_PVL the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_MODPGD_cur18 is
    select *
    from i$SDD_MODPGD the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_MUN_cur19 is
    select *
    from i$SDD_MUN the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_IGR_cur20 is
    select *
    from i$SDD_IGR the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_ITE_cur21 is
    select *
    from i$SDD_ITE the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_MTI_cur22 is
    select *
    from i$SDD_MTI the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_CNU_cur23 is
    select *
    from i$SDD_CNU the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_SQS_cur24 is
    select *
    from i$SDD_SQS the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_PGD_cur25 is
    select *
    from i$SDD_PGD the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
  cursor SDD_WIN_cur26 is
    select *
    from i$SDD_WIN the_tab
    where the_tab.parent_ivid=SDD_ORT_ver.ivid;
begin
  new_ivid := jr_system_util.get_new_ivid;
  open SDD_ORT_cur;
  fetch SDD_ORT_cur into SDD_ORT_rec;
  close SDD_ORT_cur;
  insert into i$SDD_ORT
  values (
    SDD_ORT_rec.irid -- irid
   ,new_ivid -- ivid
   ,SDD_ORT_rec.TYPES
   ,SDD_ORT_rec.ELEMENT_TYPE_NAME
   ,SDD_ORT_rec.DATE_CREATED
   ,SDD_ORT_rec.CREATED_BY
   ,SDD_ORT_rec.DATE_CHANGED
   ,SDD_ORT_rec.CHANGED_BY
   ,SDD_ORT_rec.NOTM
   ,SDD_ORT_rec.NAME
   ,SDD_ORT_rec.COLLECTION_TYPE
   ,SDD_ORT_rec.VARRAY_LIMIT
   ,SDD_ORT_rec.COLLECTION_OF
   ,SDD_ORT_rec.SCALAR_DATATYPE
   ,SDD_ORT_rec.SCALAR_MAXIMUM_LENGTH
   ,SDD_ORT_rec.SCALAR_DECIMAL_PLACES
   ,SDD_ORT_rec.ORACLE_OBJECT_TYPE_REF
   ,SDD_ORT_rec.OBJECT_REF_FLAG
   ,SDD_ORT_rec.REMARK
   ,SDD_ORT_rec.ORT_TYPE
   ,SDD_ORT_rec.USRX0
   ,SDD_ORT_rec.USRX1
   ,SDD_ORT_rec.USRX2
   ,SDD_ORT_rec.USRX3
   ,SDD_ORT_rec.USRX4
   ,SDD_ORT_rec.USRX5
   ,SDD_ORT_rec.USRX6
   ,SDD_ORT_rec.USRX7
   ,SDD_ORT_rec.USRX8
   ,SDD_ORT_rec.USRX9
   ,SDD_ORT_rec.USRX10
   ,SDD_ORT_rec.USRX11
   ,SDD_ORT_rec.USRX12
   ,SDD_ORT_rec.USRX13
   ,SDD_ORT_rec.USRX14
   ,SDD_ORT_rec.USRX15
   ,SDD_ORT_rec.USRX16
   ,SDD_ORT_rec.USRX17
   ,SDD_ORT_rec.USRX18
   ,SDD_ORT_rec.USRX19
  );
  jr_reg_ver.vercopy_dependencies(SDD_ORT_ver.irid, SDD_ORT_ver.ivid, new_ivid, null, copy_dependencies);
  for SDD_COL_rec1 in SDD_COL_cur1 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_COL
    values (
       SDD_COL_rec1.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_COL_rec1.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_COL_rec1.TYPES
     , SDD_COL_rec1.ELEMENT_TYPE_NAME
     , SDD_COL_rec1.DATE_CREATED
     , SDD_COL_rec1.CREATED_BY
     , SDD_COL_rec1.DATE_CHANGED
     , SDD_COL_rec1.CHANGED_BY
     , SDD_COL_rec1.NOTM
     , SDD_COL_rec1.TABLE_REF
     , SDD_COL_rec1.ORACLE_OBJECT_TYPE_REF
     , SDD_COL_rec1.NAME
     , SDD_COL_rec1.SEQUENCE_NUMBER
     , SDD_COL_rec1.COMPLETE_FLAG
     , SDD_COL_rec1.DOMAIN_REF
     , SDD_COL_rec1.DATATYPE
     , SDD_COL_rec1.AVERAGE_LENGTH
     , SDD_COL_rec1.MAXIMUM_LENGTH
     , SDD_COL_rec1.DECIMAL_PLACES
     , SDD_COL_rec1.ORACLE_TYPE_REF
     , SDD_COL_rec1.OBJECT_TYPE_INCLUSION
     , SDD_COL_rec1.SCOPE_TABLE_REF
     , SDD_COL_rec1.STORE_REF_WITH_ROWID_FLAG
     , SDD_COL_rec1.NULL_INDICATOR
     , SDD_COL_rec1.UPPERCASE
     , SDD_COL_rec1.DEFAULT_VALUE
     , SDD_COL_rec1.DEFAULT_VALUE_TYPE
     , SDD_COL_rec1.SEQUENCE_REF
     , SDD_COL_rec1.CLUSTER_COLUMN_REF
     , SDD_COL_rec1.INITIAL_VOLUME
     , SDD_COL_rec1.FINAL_VOLUME
     , SDD_COL_rec1.DISPLAY_FLAG
     , SDD_COL_rec1.DEFAULT_IMPLEMENTATION_ITEM
     , SDD_COL_rec1.DEFAULT_DISPLAY_TYPE
     , SDD_COL_rec1.JUSTIFICATION
     , SDD_COL_rec1.DISPLAY_LENGTH
     , SDD_COL_rec1.DISPLAY_HEIGHT
     , SDD_COL_rec1.DISPLAY_SEQUENCE
     , SDD_COL_rec1.DESCRIPTOR_COLUMN
     , SDD_COL_rec1.FORMAT_MODIFIER
     , SDD_COL_rec1.HIGHLIGHTING
     , SDD_COL_rec1.SOURCE_RELATIONSHIP_END
     , SDD_COL_rec1.PROMPT
     , SDD_COL_rec1.SOURCE_ENTITY_DERIVED_FROM
     , SDD_COL_rec1.SOURCE_REL_ENTITY_ATTRIBUTE
     , SDD_COL_rec1.SOURCE_REL_ENTITY
     , SDD_COL_rec1.ORDER_SEQUENCE
     , SDD_COL_rec1.SORTING_ORDER
     , SDD_COL_rec1.BASE_COLUMN_REF
     , SDD_COL_rec1.RELATION_SELECTION_REF
     , SDD_COL_rec1.EXPRESSION_TEXT
     , SDD_COL_rec1.RELATION_TYPE
     , SDD_COL_rec1.COLUMN_FOR
     , SDD_COL_rec1.COLUMN_DENORMALISED_FROM
     , SDD_COL_rec1.CONSTRAINT_DENORMALISED_VIA
     , SDD_COL_rec1.DENORMALIZED_SUMMARY_FUNCTION
     , SDD_COL_rec1.AUTO_GENERATED
     , SDD_COL_rec1.SERVER_DEFAULTED_FLAG
     , SDD_COL_rec1.SERVER_DERIVED_FLAG
     , SDD_COL_rec1.DERIVATION_EXPRESSION_TYPE
     , SDD_COL_rec1.SOURCE_ATTRIBUTE_REF
     , SDD_COL_rec1.SUGGESTION_LIST_FLAG
     , SDD_COL_rec1.SOFT_LOV
     , SDD_COL_rec1.WHERE_VALIDATION_TYPE
     , SDD_COL_rec1.VALIDATION_FAILURE_MESSAGE
     , SDD_COL_rec1.HELP_TEXT
     , SDD_COL_rec1.REMARK
     , SDD_COL_rec1.FIELD_LEVEL
     , SDD_COL_rec1.SIGNED
     , SDD_COL_rec1.FIELD_INITIAL_VALUE
     , SDD_COL_rec1.FIELD_NULL_VALUE
     , SDD_COL_rec1.STORAGE_FORMAT
     , SDD_COL_rec1.REDEFINES
     , SDD_COL_rec1.OCCURS
     , SDD_COL_rec1.USRX0
     , SDD_COL_rec1.USRX1
     , SDD_COL_rec1.USRX2
     , SDD_COL_rec1.USRX3
     , SDD_COL_rec1.USRX4
     , SDD_COL_rec1.USRX5
     , SDD_COL_rec1.USRX6
     , SDD_COL_rec1.USRX7
     , SDD_COL_rec1.USRX8
     , SDD_COL_rec1.USRX9
     , SDD_COL_rec1.USRX10
     , SDD_COL_rec1.USRX11
     , SDD_COL_rec1.USRX12
     , SDD_COL_rec1.USRX13
     , SDD_COL_rec1.USRX14
     , SDD_COL_rec1.USRX15
     , SDD_COL_rec1.USRX16
     , SDD_COL_rec1.USRX17
     , SDD_COL_rec1.USRX18
     , SDD_COL_rec1.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_COL_rec1.irid, SDD_COL_rec1.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_ATV_rec2 in SDD_ATV_cur2 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ATV
    values (
       SDD_ATV_rec2.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ATV_rec2.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ATV_rec2.TYPES
     , SDD_ATV_rec2.ELEMENT_TYPE_NAME
     , SDD_ATV_rec2.DATE_CREATED
     , SDD_ATV_rec2.CREATED_BY
     , SDD_ATV_rec2.DATE_CHANGED
     , SDD_ATV_rec2.CHANGED_BY
     , SDD_ATV_rec2.NOTM
     , SDD_ATV_rec2.ATTRIBUTE_REF
     , SDD_ATV_rec2.DOMAIN_REF
     , SDD_ATV_rec2.COLUMN_REF
     , SDD_ATV_rec2.MODULE_ARGUMENT_REF
     , SDD_ATV_rec2.UNBOUND_ITEM_REF
     , SDD_ATV_rec2.LOW_VALUE
     , SDD_ATV_rec2.HIGH_VALUE
     , SDD_ATV_rec2.ABBREVIATION
     , SDD_ATV_rec2.LOW_VALUE_TYPE
     , SDD_ATV_rec2.MEANING
     , SDD_ATV_rec2.HIGH_VALUE_TYPE
     , SDD_ATV_rec2.RADIO_SEQUENCE
     , SDD_ATV_rec2.ATTRIBUTE_VALUE_FOR
     , SDD_ATV_rec2.USRX0
     , SDD_ATV_rec2.USRX1
     , SDD_ATV_rec2.USRX2
     , SDD_ATV_rec2.USRX3
     , SDD_ATV_rec2.USRX4
     , SDD_ATV_rec2.USRX5
     , SDD_ATV_rec2.USRX6
     , SDD_ATV_rec2.USRX7
     , SDD_ATV_rec2.USRX8
     , SDD_ATV_rec2.USRX9
     , SDD_ATV_rec2.USRX10
     , SDD_ATV_rec2.USRX11
     , SDD_ATV_rec2.USRX12
     , SDD_ATV_rec2.USRX13
     , SDD_ATV_rec2.USRX14
     , SDD_ATV_rec2.USRX15
     , SDD_ATV_rec2.USRX16
     , SDD_ATV_rec2.USRX17
     , SDD_ATV_rec2.USRX18
     , SDD_ATV_rec2.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ATV_rec2.irid, SDD_ATV_rec2.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_MOD_rec3 in SDD_MOD_cur3 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_MOD
    values (
       SDD_MOD_rec3.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_MOD_rec3.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_MOD_rec3.TYPES
     , SDD_MOD_rec3.ELEMENT_TYPE_NAME
     , SDD_MOD_rec3.DATE_CREATED
     , SDD_MOD_rec3.CREATED_BY
     , SDD_MOD_rec3.DATE_CHANGED
     , SDD_MOD_rec3.CHANGED_BY
     , SDD_MOD_rec3.NOTM
     , SDD_MOD_rec3.SHORT_NAME
     , SDD_MOD_rec3.NAME
     , SDD_MOD_rec3.LANGUAGE_REF
     , SDD_MOD_rec3.PURPOSE
     , SDD_MOD_rec3.JAVA_MODULE_TYPE
     , SDD_MOD_rec3.PLSQL_MODULE_TYPE
     , SDD_MOD_rec3.IMPLEMENTATION_NAME
     , SDD_MOD_rec3.SCOPE
     , SDD_MOD_rec3.JAVA_RETURN_TYPE
     , SDD_MOD_rec3.ORACLE_OBJECT_TYPE_REF
     , SDD_MOD_rec3.GENERAL_MODULE_TYPE
     , SDD_MOD_rec3.TYPE_MEMBER_ORDERING
     , SDD_MOD_rec3.TOP_TITLE
     , SDD_MOD_rec3.BOTTOM_TITLE
     , SDD_MOD_rec3.SHORT_TITLE
     , SDD_MOD_rec3.FORMAT
     , SDD_MOD_rec3.COMPLETION_STATUS
     , SDD_MOD_rec3.CANDIDATE_FLAG
     , SDD_MOD_rec3.PREVENT_GENERATION_FLAG
     , SDD_MOD_rec3.SIZE_OF_MODULE
     , SDD_MOD_rec3.COMPLEXITY
     , SDD_MOD_rec3.PROJECT_CODE
     , SDD_MOD_rec3.ACTIVITY_CODE
     , SDD_MOD_rec3.TASK_CODE
     , SDD_MOD_rec3.ESTIMATE
     , SDD_MOD_rec3.MODULE_TYPE
     , SDD_MOD_rec3.ESTIMATE_UNITS
     , SDD_MOD_rec3.TOP_LEVEL_FLAG
     , SDD_MOD_rec3.COMMAND_LINE
     , SDD_MOD_rec3.REPEATABLE_FLAG
     , SDD_MOD_rec3.RETURN_TYPE
     , SDD_MOD_rec3.ORACLE_TYPE_REF
     , SDD_MOD_rec3.RUNTIME_PATHNAME
     , SDD_MOD_rec3.WNDS_FLAG
     , SDD_MOD_rec3.WNPS_FLAG
     , SDD_MOD_rec3.RNDS_FLAG
     , SDD_MOD_rec3.RNPS_FLAG
     , SDD_MOD_rec3.FREE_FORMAT_TEXT_FLAG
     , SDD_MOD_rec3.SOURCE_PATHNAME
     , SDD_MOD_rec3.HELP_FILE_NAME
     , SDD_MOD_rec3.HELP_GRAPHIC_FILE_NAME
     , SDD_MOD_rec3.JAVA_MODULE_REF
     , SDD_MOD_rec3.JAVA_METHOD
     , SDD_MOD_rec3.JAVA_PARAMETER_LIST
     , SDD_MOD_rec3.HELP_CONTEXT_ID_PREFIX
     , SDD_MOD_rec3.USRX0
     , SDD_MOD_rec3.USRX1
     , SDD_MOD_rec3.USRX2
     , SDD_MOD_rec3.USRX3
     , SDD_MOD_rec3.USRX4
     , SDD_MOD_rec3.USRX5
     , SDD_MOD_rec3.USRX6
     , SDD_MOD_rec3.USRX7
     , SDD_MOD_rec3.USRX8
     , SDD_MOD_rec3.USRX9
     , SDD_MOD_rec3.USRX10
     , SDD_MOD_rec3.USRX11
     , SDD_MOD_rec3.USRX12
     , SDD_MOD_rec3.USRX13
     , SDD_MOD_rec3.USRX14
     , SDD_MOD_rec3.USRX15
     , SDD_MOD_rec3.USRX16
     , SDD_MOD_rec3.USRX17
     , SDD_MOD_rec3.USRX18
     , SDD_MOD_rec3.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_MOD_rec3.irid, SDD_MOD_rec3.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_ARG_rec4 in SDD_ARG_cur4 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ARG
    values (
       SDD_ARG_rec4.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ARG_rec4.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ARG_rec4.TYPES
     , SDD_ARG_rec4.ELEMENT_TYPE_NAME
     , SDD_ARG_rec4.DATE_CREATED
     , SDD_ARG_rec4.CREATED_BY
     , SDD_ARG_rec4.DATE_CHANGED
     , SDD_ARG_rec4.CHANGED_BY
     , SDD_ARG_rec4.NOTM
     , SDD_ARG_rec4.GENERAL_MODULE_REF
     , SDD_ARG_rec4.PLSQL_MODULE_REF
     , SDD_ARG_rec4.NAME
     , SDD_ARG_rec4.INPUT_OUTPUT_IDENTIFIER
     , SDD_ARG_rec4.POSITION
     , SDD_ARG_rec4.DOMAIN_REF
     , SDD_ARG_rec4.DATASTRUCTURE_REF
     , SDD_ARG_rec4.COLUMN_REF
     , SDD_ARG_rec4.TABLE_DEFINITION_REF
     , SDD_ARG_rec4.ORACLE_TYPE_REF
     , SDD_ARG_rec4.DATATYPE
     , SDD_ARG_rec4.LENGTH
     , SDD_ARG_rec4.SCALE
     , SDD_ARG_rec4.DEFAULT_VALUE
     , SDD_ARG_rec4.DEFAULT_VALUE_TYPE
     , SDD_ARG_rec4.OPTIONAL_FLAG
     , SDD_ARG_rec4.DISPLAY_FLAG
     , SDD_ARG_rec4.PROMPT
     , SDD_ARG_rec4.SOFT_LOV
     , SDD_ARG_rec4.SUGGESTION_LIST_FLAG
     , SDD_ARG_rec4.INPUT_MASK
     , SDD_ARG_rec4.SUBSTITUTION_VARIABLE
     , SDD_ARG_rec4.REMARK
     , SDD_ARG_rec4.ATTRIBUTE_OR_DATAITEM
     , SDD_ARG_rec4.MODULE_ARGUMENT_FOR
     , SDD_ARG_rec4.MODULE_TYPE_FOR
     , SDD_ARG_rec4.USRX0
     , SDD_ARG_rec4.USRX1
     , SDD_ARG_rec4.USRX2
     , SDD_ARG_rec4.USRX3
     , SDD_ARG_rec4.USRX4
     , SDD_ARG_rec4.USRX5
     , SDD_ARG_rec4.USRX6
     , SDD_ARG_rec4.USRX7
     , SDD_ARG_rec4.USRX8
     , SDD_ARG_rec4.USRX9
     , SDD_ARG_rec4.USRX10
     , SDD_ARG_rec4.USRX11
     , SDD_ARG_rec4.USRX12
     , SDD_ARG_rec4.USRX13
     , SDD_ARG_rec4.USRX14
     , SDD_ARG_rec4.USRX15
     , SDD_ARG_rec4.USRX16
     , SDD_ARG_rec4.USRX17
     , SDD_ARG_rec4.USRX18
     , SDD_ARG_rec4.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ARG_rec4.irid, SDD_ARG_rec4.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_ARGITE_rec5 in SDD_ARGITE_cur5 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ARGITE
    values (
       SDD_ARGITE_rec5.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ARGITE_rec5.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ARGITE_rec5.TYPES
     , SDD_ARGITE_rec5.ELEMENT_TYPE_NAME
     , SDD_ARGITE_rec5.DATE_CREATED
     , SDD_ARGITE_rec5.CREATED_BY
     , SDD_ARGITE_rec5.DATE_CHANGED
     , SDD_ARGITE_rec5.CHANGED_BY
     , SDD_ARGITE_rec5.NOTM
     , SDD_ARGITE_rec5.MODULE_ARGUMENT_REF
     , SDD_ARGITE_rec5.ITEM_REF
     , SDD_ARGITE_rec5.ARGUMENT_OPERATOR
     , SDD_ARGITE_rec5.SQL_QUERY_CLAUSE
     , SDD_ARGITE_rec5.USE_PRIOR_ROW_FLAG
     , SDD_ARGITE_rec5.USRX0
     , SDD_ARGITE_rec5.USRX1
     , SDD_ARGITE_rec5.USRX2
     , SDD_ARGITE_rec5.USRX3
     , SDD_ARGITE_rec5.USRX4
     , SDD_ARGITE_rec5.USRX5
     , SDD_ARGITE_rec5.USRX6
     , SDD_ARGITE_rec5.USRX7
     , SDD_ARGITE_rec5.USRX8
     , SDD_ARGITE_rec5.USRX9
     , SDD_ARGITE_rec5.USRX10
     , SDD_ARGITE_rec5.USRX11
     , SDD_ARGITE_rec5.USRX12
     , SDD_ARGITE_rec5.USRX13
     , SDD_ARGITE_rec5.USRX14
     , SDD_ARGITE_rec5.USRX15
     , SDD_ARGITE_rec5.USRX16
     , SDD_ARGITE_rec5.USRX17
     , SDD_ARGITE_rec5.USRX18
     , SDD_ARGITE_rec5.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ARGITE_rec5.irid, SDD_ARGITE_rec5.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_DAT_rec6 in SDD_DAT_cur6 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DAT
    values (
       SDD_DAT_rec6.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DAT_rec6.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DAT_rec6.TYPES
     , SDD_DAT_rec6.ELEMENT_TYPE_NAME
     , SDD_DAT_rec6.DATE_CREATED
     , SDD_DAT_rec6.CREATED_BY
     , SDD_DAT_rec6.DATE_CHANGED
     , SDD_DAT_rec6.CHANGED_BY
     , SDD_DAT_rec6.NOTM
     , SDD_DAT_rec6.PLSQL_MODULE_REF
     , SDD_DAT_rec6.NAME
     , SDD_DAT_rec6.DATASTRUCTURE_TYPE
     , SDD_DAT_rec6.SCOPE
     , SDD_DAT_rec6.REMARK
     , SDD_DAT_rec6.SEQUENCE
     , SDD_DAT_rec6.USRX0
     , SDD_DAT_rec6.USRX1
     , SDD_DAT_rec6.USRX2
     , SDD_DAT_rec6.USRX3
     , SDD_DAT_rec6.USRX4
     , SDD_DAT_rec6.USRX5
     , SDD_DAT_rec6.USRX6
     , SDD_DAT_rec6.USRX7
     , SDD_DAT_rec6.USRX8
     , SDD_DAT_rec6.USRX9
     , SDD_DAT_rec6.USRX10
     , SDD_DAT_rec6.USRX11
     , SDD_DAT_rec6.USRX12
     , SDD_DAT_rec6.USRX13
     , SDD_DAT_rec6.USRX14
     , SDD_DAT_rec6.USRX15
     , SDD_DAT_rec6.USRX16
     , SDD_DAT_rec6.USRX17
     , SDD_DAT_rec6.USRX18
     , SDD_DAT_rec6.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DAT_rec6.irid, SDD_DAT_rec6.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_ITM_rec7 in SDD_ITM_cur7 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_ITM
    values (
       SDD_ITM_rec7.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_ITM_rec7.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_ITM_rec7.TYPES
     , SDD_ITM_rec7.ELEMENT_TYPE_NAME
     , SDD_ITM_rec7.DATE_CREATED
     , SDD_ITM_rec7.CREATED_BY
     , SDD_ITM_rec7.DATE_CHANGED
     , SDD_ITM_rec7.CHANGED_BY
     , SDD_ITM_rec7.NOTM
     , SDD_ITM_rec7.DATASTRUCTURE_REF
     , SDD_ITM_rec7.NAME
     , SDD_ITM_rec7.SEQUENCE
     , SDD_ITM_rec7.DOMAIN_REF
     , SDD_ITM_rec7.TABLE_DEFINITION_REF
     , SDD_ITM_rec7.COLUMN_REF
     , SDD_ITM_rec7.ORACLE_TYPE_REF
     , SDD_ITM_rec7.DATASTRUCTURE_REF2
     , SDD_ITM_rec7.PROGRAM_DATUM_REF
     , SDD_ITM_rec7.PLSQL_MODULE_REF
     , SDD_ITM_rec7.CURSOR_REF
     , SDD_ITM_rec7.DATATYPE
     , SDD_ITM_rec7.MAXIMUM_LENGTH
     , SDD_ITM_rec7.SCALE
     , SDD_ITM_rec7.DEFAULT_VALUE
     , SDD_ITM_rec7.DEFAULT_VALUE_TYPE
     , SDD_ITM_rec7.NULLS
     , SDD_ITM_rec7.ITEM_TYPE
     , SDD_ITM_rec7.CQA_REF
     , SDD_ITM_rec7.USRX0
     , SDD_ITM_rec7.USRX1
     , SDD_ITM_rec7.USRX2
     , SDD_ITM_rec7.USRX3
     , SDD_ITM_rec7.USRX4
     , SDD_ITM_rec7.USRX5
     , SDD_ITM_rec7.USRX6
     , SDD_ITM_rec7.USRX7
     , SDD_ITM_rec7.USRX8
     , SDD_ITM_rec7.USRX9
     , SDD_ITM_rec7.USRX10
     , SDD_ITM_rec7.USRX11
     , SDD_ITM_rec7.USRX12
     , SDD_ITM_rec7.USRX13
     , SDD_ITM_rec7.USRX14
     , SDD_ITM_rec7.USRX15
     , SDD_ITM_rec7.USRX16
     , SDD_ITM_rec7.USRX17
     , SDD_ITM_rec7.USRX18
     , SDD_ITM_rec7.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_ITM_rec7.irid, SDD_ITM_rec7.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_DSY_rec8 in SDD_DSY_cur8 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
    insert into i$SDD_DSY
    values (
       SDD_DSY_rec8.irid    -- irid
     , new_secondary_ivid                   -- ivid
     , SDD_DSY_rec8.pac_ref -- pac_ref
     , new_ivid                             -- parent_ivid
     , SDD_DSY_rec8.TYPES
     , SDD_DSY_rec8.ELEMENT_TYPE_NAME
     , SDD_DSY_rec8.DATE_CREATED
     , SDD_DSY_rec8.CREATED_BY
     , SDD_DSY_rec8.DATE_CHANGED
     , SDD_DSY_rec8.CHANGED_BY
     , SDD_DSY_rec8.NOTM
     , SDD_DSY_rec8.TABLE_DEFINITION_REF
     , SDD_DSY_rec8.VIEW_DEFINITION_REF
     , SDD_DSY_rec8.SNAPSHOT_DEFINITION_REF
     , SDD_DSY_rec8.SEQUENCE_REF
     , SDD_DSY_rec8.PLSQL_MODULE_REF
     , SDD_DSY_rec8.JAVA_MODULE_REF
     , SDD_DSY_rec8.NAME
     , SDD_DSY_rec8.SCOPE
     , SDD_DSY_rec8.COMPLETE_FLAG
     , SDD_DSY_rec8.SYNONYM_FOR
     , SDD_DSY_rec8.USRX0
     , SDD_DSY_rec8.USRX1
     , SDD_DSY_rec8.USRX2
     , SDD_DSY_rec8.USRX3
     , SDD_DSY_rec8.USRX4
     , SDD_DSY_rec8.USRX5
     , SDD_DSY_rec8.USRX6
     , SDD_DSY_rec8.USRX7
     , SDD_DSY_rec8.USRX8
     , SDD_DSY_rec8.USRX9
     , SDD_DSY_rec8.USRX10
     , SDD_DSY_rec8.USRX11
     , SDD_DSY_rec8.USRX12
     , SDD_DSY_rec8.USRX13
     , SDD_DSY_rec8.USRX14
     , SDD_DSY_rec8.USRX15
     , SDD_DSY_rec8.USRX16
     , SDD_DSY_rec8.USRX17
     , SDD_DSY_rec8.USRX18
     , SDD_DSY_rec8.USRX19
    );
  jr_reg_ver.vercopy_dependencies(SDD_DSY_rec8.irid, SDD_DSY_rec8.ivid, new_secondary_ivid, new_ivid, copy_dependencies);
  end loop;
  for SDD_LVI_rec9 in SDD_LVI_cur9 loop
    new_secondary_ivid := jr_system_util.get_new_ivid;
