begin
                                                       
update GK_SPR_LS set TYPE_ORG = 1 where TYPE_ORG is null and TYPE_REPO is not null;

insert into DEF_VARS_V (ID,VAR_OID,D_BEG,D_END,VARVALUE,USER_ID)
VALUES (MAINID.NEXTVAL,1002844,to_date('01.01.2000','dd.mm.yyyy'),to_date('12.12.4000','dd.mm.yyyy'),40,null);

insert into DEF_VARS_V (ID,VAR_OID,D_BEG,D_END,VARVALUE,USER_ID)
VALUES (MAINID.NEXTVAL,1002846,to_date('01.01.2000','dd.mm.yyyy'),to_date('12.12.4000','dd.mm.yyyy'),60,null);

insert into GK_SETTING_COMLS (ID,S_CR,S_CDT,S_MR,S_MDT,DBEG,PORTFEL,PGROUP,ID_GROUP_BIND,DEND,CLOSE_LS,LSOPEN,TYPE_CB,TWONESS_LS,ISSUER_LS,LS_CUT,NEREZ,DAYS_TO_CLOSE,LS_TYPE,PRIV_PORTFEL,TYPE_CONTR,VL_ISSUER,HAVE_PR_DEF,PR_DEF_CAT,LSMASK,NAME,NBSID,VALUTID,PFIXLS,BACKUP_ID)
select mainid.nextval,dbo.S_CONTEXT(1),sysdate,dbo.S_CONTEXT(1),sysdate,to_date('01.01.2019','DD.MM.YYYY'),0,0,null,null,null,1,1,null,null,2,null,null,430,(select P.ID from COM_VIEW_DOST_PORTF P where P.CODE = null),null,null,null,null,null,null,null,null,1,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810021004210301'),1,null,0,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,9,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810821004210802'),0,null,1,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,9,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810521004210801'),0,null,0,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,8,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810921004210702'),0,null,1,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,7,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810721004210601'),0,null,1,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810221004210402'),2,null,1,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810921004210401'),2,null,0,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810821004210501'),0,null,0,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,5,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810921004210401'),0,null,0,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,5,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810221004210402'),0,null,1,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,4,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810121004210201'),0,null,0,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810221004210101'),0,null,0,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810521004210102'),0,null,1,null,null,5414906972 from dual;

update GK_SETTING_COMLS
   set TWONESS_LS = (select A.ID from GK_SETTING_COMLS A where A.BACKUP_ID = GK_SETTING_COMLS.TWONESS_LS)
 where BACKUP_ID in (5414906972)
   and TWONESS_LS is not null;

update GK_SETTING_COMLS_T
   set VNESHID = (select ID from GK_SETTING_COMLS where BACKUP_ID = GK_SETTING_COMLS_T.BACKUP_VNESHID)
 where BACKUP_VNESHID in (5414906972);

update GK_SETTING_COMLS
   set BACKUP_ID = null
 where BACKUP_ID in (5414906972);
update GK_SETTING_COMLS_T
   set BACKUP_VNESHID = null
 where BACKUP_VNESHID in (5414906972);

insert into GK_SETTING_COMLS (ID,S_CR,S_CDT,S_MR,S_MDT,DBEG,PORTFEL,PGROUP,ID_GROUP_BIND,DEND,CLOSE_LS,LSOPEN,TYPE_CB,TWONESS_LS,ISSUER_LS,LS_CUT,NEREZ,DAYS_TO_CLOSE,LS_TYPE,PRIV_PORTFEL,TYPE_CONTR,VL_ISSUER,HAVE_PR_DEF,PR_DEF_CAT,LSMASK,NAME,NBSID,VALUTID,PFIXLS,BACKUP_ID)
select mainid.nextval,dbo.S_CONTEXT(1),sysdate,dbo.S_CONTEXT(1),sysdate,to_date('01.01.2019','DD.MM.YYYY'),0,0,null,null,null,1,1,null,null,2,null,null,431,(select P.ID from COM_VIEW_DOST_PORTF P where P.CODE = null),null,null,null,null,null,null,null,null,1,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810021004210301'),1,null,0,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,9,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810821004210802'),0,null,1,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,9,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810521004210801'),0,null,0,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,8,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810921004210702'),0,null,1,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,7,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810721004210601'),0,null,1,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810221004210402'),2,null,1,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810921004210401'),2,null,0,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810821004210501'),0,null,0,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,5,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810921004210401'),0,null,0,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,5,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810221004210402'),0,null,1,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,4,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810121004210201'),0,null,0,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810221004210101'),0,null,0,null,null,5414906972 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810521004210102'),0,null,1,null,null,5414906972 from dual;

update GK_SETTING_COMLS
   set TWONESS_LS = (select A.ID from GK_SETTING_COMLS A where A.BACKUP_ID = GK_SETTING_COMLS.TWONESS_LS)
 where BACKUP_ID in (5414906972)
   and TWONESS_LS is not null;

update GK_SETTING_COMLS_T
   set VNESHID = (select ID from GK_SETTING_COMLS where BACKUP_ID = GK_SETTING_COMLS_T.BACKUP_VNESHID)
 where BACKUP_VNESHID in (5414906972);

update GK_SETTING_COMLS
   set BACKUP_ID = null
 where BACKUP_ID in (5414906972);
update GK_SETTING_COMLS_T
   set BACKUP_VNESHID = null
 where BACKUP_VNESHID in (5414906972);

insert into GK_SETTING_COMLS (ID,S_CR,S_CDT,S_MR,S_MDT,DBEG,PORTFEL,PGROUP,ID_GROUP_BIND,DEND,CLOSE_LS,LSOPEN,TYPE_CB,TWONESS_LS,ISSUER_LS,LS_CUT,NEREZ,DAYS_TO_CLOSE,LS_TYPE,PRIV_PORTFEL,TYPE_CONTR,VL_ISSUER,HAVE_PR_DEF,PR_DEF_CAT,LSMASK,NAME,NBSID,VALUTID,PFIXLS,BACKUP_ID)
select mainid.nextval,dbo.S_CONTEXT(1),sysdate,dbo.S_CONTEXT(1),sysdate,to_date('01.01.2016','DD.MM.YYYY'),2,0,null,null,null,1,1,null,null,2,null,null,430,(select P.ID from COM_VIEW_DOST_PORTF P where P.CODE = null),null,null,null,null,null,null,null,null,1,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810721004230102'),0,null,1,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810221004230301'),1,null,0,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810321004230502'),0,null,1,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810421004230402'),2,null,1,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810121004230401'),2,null,0,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,9,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810721004230801'),0,null,1,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,9,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810021004230802'),0,null,0,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,8,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810821004230701'),0,null,1,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,7,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810921004230601'),0,null,1,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810021004230501'),0,null,0,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,5,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810121004230401'),0,null,0,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,5,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810421004230402'),0,null,1,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,4,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810321004230201'),0,null,0,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810421004230101'),0,null,0,null,null,4023700016 from dual;

update GK_SETTING_COMLS
   set TWONESS_LS = (select A.ID from GK_SETTING_COMLS A where A.BACKUP_ID = GK_SETTING_COMLS.TWONESS_LS)
 where BACKUP_ID in (4023700016)
   and TWONESS_LS is not null;

update GK_SETTING_COMLS_T
   set VNESHID = (select ID from GK_SETTING_COMLS where BACKUP_ID = GK_SETTING_COMLS_T.BACKUP_VNESHID)
 where BACKUP_VNESHID in (4023700016);

update GK_SETTING_COMLS
   set BACKUP_ID = null
 where BACKUP_ID in (4023700016);
update GK_SETTING_COMLS_T
   set BACKUP_VNESHID = null
 where BACKUP_VNESHID in (4023700016);


insert into GK_SETTING_COMLS (ID,S_CR,S_CDT,S_MR,S_MDT,DBEG,PORTFEL,PGROUP,ID_GROUP_BIND,DEND,CLOSE_LS,LSOPEN,TYPE_CB,TWONESS_LS,ISSUER_LS,LS_CUT,NEREZ,DAYS_TO_CLOSE,LS_TYPE,PRIV_PORTFEL,TYPE_CONTR,VL_ISSUER,HAVE_PR_DEF,PR_DEF_CAT,LSMASK,NAME,NBSID,VALUTID,PFIXLS,BACKUP_ID)
select mainid.nextval,dbo.S_CONTEXT(1),sysdate,dbo.S_CONTEXT(1),sysdate,to_date('01.01.2016','DD.MM.YYYY'),2,0,null,null,null,1,1,null,null,2,null,null,431,(select P.ID from COM_VIEW_DOST_PORTF P where P.CODE = null),null,null,null,null,null,null,null,null,1,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810721004230102'),0,null,1,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810221004230301'),1,null,0,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810321004230502'),0,null,1,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810421004230402'),2,null,1,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810121004230401'),2,null,0,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,9,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810721004230801'),0,null,1,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,9,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810021004230802'),0,null,0,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,8,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810821004230701'),0,null,1,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,7,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810921004230601'),0,null,1,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810021004230501'),0,null,0,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,5,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810121004230401'),0,null,0,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,5,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810421004230402'),0,null,1,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,4,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810321004230201'),0,null,0,null,null,4023700016 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,1,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810421004230101'),0,null,0,null,null,4023700016 from dual;

update GK_SETTING_COMLS
   set TWONESS_LS = (select A.ID from GK_SETTING_COMLS A where A.BACKUP_ID = GK_SETTING_COMLS.TWONESS_LS)
 where BACKUP_ID in (4023700016)
   and TWONESS_LS is not null;

update GK_SETTING_COMLS_T
   set VNESHID = (select ID from GK_SETTING_COMLS where BACKUP_ID = GK_SETTING_COMLS_T.BACKUP_VNESHID)
 where BACKUP_VNESHID in (4023700016);

update GK_SETTING_COMLS
   set BACKUP_ID = null
 where BACKUP_ID in (4023700016);
update GK_SETTING_COMLS_T
   set BACKUP_VNESHID = null
 where BACKUP_VNESHID in (4023700016);


insert into GK_SETTING_COMLS (ID,S_CR,S_CDT,S_MR,S_MDT,DBEG,PORTFEL,PGROUP,ID_GROUP_BIND,DEND,CLOSE_LS,LSOPEN,TYPE_CB,TWONESS_LS,ISSUER_LS,LS_CUT,NEREZ,DAYS_TO_CLOSE,LS_TYPE,PRIV_PORTFEL,TYPE_CONTR,VL_ISSUER,HAVE_PR_DEF,PR_DEF_CAT,LSMASK,NAME,NBSID,VALUTID,PFIXLS,BACKUP_ID)
select mainid.nextval,dbo.S_CONTEXT(1),sysdate,dbo.S_CONTEXT(1),sysdate,to_date('20.07.2022','DD.MM.YYYY'),4,0,null,null,null,1,1,null,null,2,null,null,430,(select P.ID from COM_VIEW_DOST_PORTF P where P.CODE = null),null,100,100,null,null,null,null,null,1,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810321004240301'),1,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810521004240101'),0,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,4,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810421004240201'),0,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,5,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810221004240401'),0,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810221004240401'),2,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810121004240501'),0,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,7,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = null),0,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,9,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = null),0,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,9,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = null),3,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = null),1,null,1,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810821004240102'),0,null,1,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,5,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810521004240402'),0,null,1,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810521004240402'),2,null,1,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810421004240502'),0,null,1,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,7,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810021004240601'),0,null,1,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,8,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810921004240701'),0,null,1,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,9,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810821004240801'),0,null,1,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,9,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = null),3,null,1,null,null,387 from dual;

update GK_SETTING_COMLS
   set TWONESS_LS = (select A.ID from GK_SETTING_COMLS A where A.BACKUP_ID = GK_SETTING_COMLS.TWONESS_LS)
 where BACKUP_ID in (387)
   and TWONESS_LS is not null;

update GK_SETTING_COMLS_T
   set VNESHID = (select ID from GK_SETTING_COMLS where BACKUP_ID = GK_SETTING_COMLS_T.BACKUP_VNESHID)
 where BACKUP_VNESHID in (387);

update GK_SETTING_COMLS
   set BACKUP_ID = null
 where BACKUP_ID in (387);
update GK_SETTING_COMLS_T
   set BACKUP_VNESHID = null
 where BACKUP_VNESHID in (387);

insert into GK_SETTING_COMLS (ID,S_CR,S_CDT,S_MR,S_MDT,DBEG,PORTFEL,PGROUP,ID_GROUP_BIND,DEND,CLOSE_LS,LSOPEN,TYPE_CB,TWONESS_LS,ISSUER_LS,LS_CUT,NEREZ,DAYS_TO_CLOSE,LS_TYPE,PRIV_PORTFEL,TYPE_CONTR,VL_ISSUER,HAVE_PR_DEF,PR_DEF_CAT,LSMASK,NAME,NBSID,VALUTID,PFIXLS,BACKUP_ID)
select mainid.nextval,dbo.S_CONTEXT(1),sysdate,dbo.S_CONTEXT(1),sysdate,to_date('20.07.2022','DD.MM.YYYY'),4,0,null,null,null,1,1,null,null,2,null,null,431,(select P.ID from COM_VIEW_DOST_PORTF P where P.CODE = null),null,100,100,null,null,null,null,null,1,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810321004240301'),1,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810521004240101'),0,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,4,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810421004240201'),0,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,5,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810221004240401'),0,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810221004240401'),2,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810121004240501'),0,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,7,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = null),0,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,9,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = null),0,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,9,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = null),3,null,0,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = null),1,null,1,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,1,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810821004240102'),0,null,1,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,5,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810521004240402'),0,null,1,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810521004240402'),2,null,1,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,6,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810421004240502'),0,null,1,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,7,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810021004240601'),0,null,1,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,8,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810921004240701'),0,null,1,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,9,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = '70606810821004240801'),0,null,1,null,null,387 from dual;

insert into GK_SETTING_COMLS_T (ID,VNESHID,ID_TYPE,NBSID,VALUTID,LSMASK,NAME,PCAP,PFIXLS,LSID,BANKRF,DOHRASHOID302,CB_NOMIN_TYPE,DOHRASHOID446,REMARK,BACKUP_VNESHID)
select mainid.nextval,-200,9,null,null,null,null,null,1,(select LS.ID from RKO_LS LS where LS.N20 = null),3,null,1,null,null,387 from dual;

update GK_SETTING_COMLS
   set TWONESS_LS = (select A.ID from GK_SETTING_COMLS A where A.BACKUP_ID = GK_SETTING_COMLS.TWONESS_LS)
 where BACKUP_ID in (387)
   and TWONESS_LS is not null;

update GK_SETTING_COMLS_T
   set VNESHID = (select ID from GK_SETTING_COMLS where BACKUP_ID = GK_SETTING_COMLS_T.BACKUP_VNESHID)
 where BACKUP_VNESHID in (387);

update GK_SETTING_COMLS
   set BACKUP_ID = null
 where BACKUP_ID in (387);
update GK_SETTING_COMLS_T
   set BACKUP_VNESHID = null
 where BACKUP_VNESHID in (387);

delete from GK_SETTING_COMLS_T 
 where CB_NOMIN_TYPE = 1
   and exists(select 1 from GK_SETTING_COMLS where GK_SETTING_COMLS.LS_TYPE = 430 and GK_SETTING_COMLS.ID = GK_SETTING_COMLS_T.VNESHID);

delete from GK_SETTING_COMLS_T 
 where CB_NOMIN_TYPE = 0
   and exists(select 1 from GK_SETTING_COMLS where GK_SETTING_COMLS.LS_TYPE = 431 and GK_SETTING_COMLS.ID = GK_SETTING_COMLS_T.VNESHID);

update GK_SETTING_COMLS_T
   set CB_NOMIN_TYPE = null
 where CB_NOMIN_TYPE is not null
   and exists(select 1 from GK_SETTING_COMLS where GK_SETTING_COMLS.LS_TYPE in (430,431) and GK_SETTING_COMLS.ID = GK_SETTING_COMLS_T.VNESHID);
end;
