--da eseguire come utente DBCGO

-------------------------------------------------------------------------
--DBCGO_LOV - filtro SOTTOCANALE_ACQUISIZIONE

INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ','AS','AS');
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ','BP','BP');
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ','CA','CA');
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ','DD','DD');
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ','DE','DE');
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ','DF','DF');
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ','DG','DG');
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ','DN','DN');
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ','GD','GD');
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ','GS','GS');
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ','PM','PM');
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ','PS','PS');
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ','PV','PV');
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ','TD','TD');
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ','TS','TS');
       

INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR, ORDER_BY) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ_GRP', '0', 'Non Definito',7);
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR, ORDER_BY) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ_GRP', 'TD', 'Telesales Diretto',5);
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR, ORDER_BY) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ_GRP', 'TS', 'Telesales Indiretto',6);
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR, ORDER_BY) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ_GRP', 'DD', 'Door to Door',4);
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR, ORDER_BY) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ_GRP', 'AS', 'Agent Sales',1);
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR, ORDER_BY) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ_GRP', 'CA', 'Car',2);
INSERT INTO DBCGO_LOV(LOV_ID, LOV_NAME, NAME, DESCR, ORDER_BY) VALUES (SEQ_LOV.nextval, 'SOTTOCAN_ACQ_GRP', 'DG', 'DG(NGO)',3);

insert into DBCGO_LOV_REF(lov_id, lov_id_ref) select lov_id,lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ' and name='AS';
insert into DBCGO_LOV_REF(lov_id, lov_id_ref) select lov_id,lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ' and name='BP';
insert into DBCGO_LOV_REF(lov_id, lov_id_ref) select lov_id,lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ' and name='CA';
insert into DBCGO_LOV_REF(lov_id, lov_id_ref) select lov_id,lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ' and name='DD';
insert into DBCGO_LOV_REF(lov_id, lov_id_ref) select lov_id,lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ' and name='DE';
insert into DBCGO_LOV_REF(lov_id, lov_id_ref) select lov_id,lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ' and name='DF';
insert into DBCGO_LOV_REF(lov_id, lov_id_ref) select lov_id,lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ' and name='DG';
insert into DBCGO_LOV_REF(lov_id, lov_id_ref) select lov_id,lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ' and name='DN';
insert into DBCGO_LOV_REF(lov_id, lov_id_ref) select lov_id,lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ' and name='GD';
insert into DBCGO_LOV_REF(lov_id, lov_id_ref) select lov_id,lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ' and name='GS';
insert into DBCGO_LOV_REF(lov_id, lov_id_ref) select lov_id,lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ' and name='PM';
insert into DBCGO_LOV_REF(lov_id, lov_id_ref) select lov_id,lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ' and name='PS';
insert into DBCGO_LOV_REF(lov_id, lov_id_ref) select lov_id,lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ' and name='PV';
insert into DBCGO_LOV_REF(lov_id, lov_id_ref) select lov_id,lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ' and name='TD';
insert into DBCGO_LOV_REF(lov_id, lov_id_ref) select lov_id,lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ' and name='TS';                                                                                                                        
                                                                                                                          
update DBCGO_LOV_REF set lov_id_ref = (select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ_GRP'	and name='AS') where lov_id=(select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ'	and name='AS') ;
update DBCGO_LOV_REF set lov_id_ref = (select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ_GRP'	and name='0') where lov_id=(select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ'	and name='BP') ;
update DBCGO_LOV_REF set lov_id_ref = (select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ_GRP'	and name='CA') where lov_id=(select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ'	and name='CA') ;
update DBCGO_LOV_REF set lov_id_ref = (select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ_GRP'	and name='DD') where lov_id=(select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ'	and name='DD') ;
update DBCGO_LOV_REF set lov_id_ref = (select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ_GRP'	and name='0') where lov_id=(select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ'	and name='DE') ;
update DBCGO_LOV_REF set lov_id_ref = (select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ_GRP'	and name='0') where lov_id=(select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ'	and name='DF') ;
update DBCGO_LOV_REF set lov_id_ref = (select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ_GRP'	and name='DG') where lov_id=(select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ'	and name='DG') ;
update DBCGO_LOV_REF set lov_id_ref = (select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ_GRP'	and name='0') where lov_id=(select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ'	and name='DN') ;
update DBCGO_LOV_REF set lov_id_ref = (select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ_GRP'	and name='0') where lov_id=(select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ'	and name='GD') ;
update DBCGO_LOV_REF set lov_id_ref = (select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ_GRP'	and name='0') where lov_id=(select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ'	and name='GS') ;
update DBCGO_LOV_REF set lov_id_ref = (select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ_GRP'	and name='0') where lov_id=(select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ'	and name='PM') ;
update DBCGO_LOV_REF set lov_id_ref = (select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ_GRP'	and name='0') where lov_id=(select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ'	and name='PS') ;
update DBCGO_LOV_REF set lov_id_ref = (select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ_GRP'	and name='0') where lov_id=(select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ'	and name='PV') ;
update DBCGO_LOV_REF set lov_id_ref = (select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ_GRP'	and name='TD') where lov_id=(select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ'	and name='TD') ;
update DBCGO_LOV_REF set lov_id_ref = (select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ_GRP'	and name='TS') where lov_id=(select lov_id from DBCGO_LOV where lov_name='SOTTOCAN_ACQ'	and name='TS') ;

--SAP_ANAG_FV dealer fittizi
insert into SAP_ANAG_FV(COD_ID, COD_ID_PADRE, MERCATO, DISLOCAZIONE_TERR, STATO, DEALER_TYPE,CANALE_ACQUISIZIONE,SOTTOCANALE_ACQUISIZIONE) values ('142','142','TS','TS',1,1,'PUSH','DG'); 
insert into SAP_ANAG_FV(COD_ID, COD_ID_PADRE, MERCATO, DISLOCAZIONE_TERR, STATO, DEALER_TYPE,CANALE_ACQUISIZIONE,SOTTOCANALE_ACQUISIZIONE,SEGMENTAZIONE_CANALE) values ('143','143','TS','TS',1,1,'PUSH','TD','TD'); 

update SAP_ANAG_FV set CANALE_ACQUISIZIONE='PUSH',SOTTOCANALE_ACQUISIZIONE='TS',SEGMENTAZIONE_CANALE='TS' where cod_id='140';
update SAP_ANAG_FV set CANALE_ACQUISIZIONE='PUSH',SOTTOCANALE_ACQUISIZIONE='TS',SEGMENTAZIONE_CANALE='TS' where cod_id='141';

-------------------------------------------------------------------------
commit;


















