create or replace PROCEDURE EMPTY_ROUTING_VERSION (NEP_VERSION_ID IN VARCHAR2)
AS
BEGIN
       DELETE FROM LEVEL1LINK WHERE VERSIONID = NEP_VERSION_ID;
       DELETE FROM DIMTRAFFICALLOCATION WHERE VERSIONID = NEP_VERSION_ID;
       DELETE FROM TRAFFICUNIT WHERE VERSIONID = NEP_VERSION_ID;
       UPDATE CIRCUITTRAFFIC SET ROUTE = null WHERE DTYPE = 'Circuit' AND VERSIONID = NEP_VERSION_ID;
       DELETE FROM CIRCUITTRAFFIC WHERE DTYPE = 'CircuitTraffic' AND VERSIONID = NEP_VERSION_ID;
       UPDATE BTSPIECE SET ROUTE = null WHERE BTSID IN (SELECT BTSID FROM BTS WHERE VERSIONID = NEP_VERSION_ID);
       commit;
END;


INSERT INTO bscpiece 
select * from bscpiece_back_22_11
where bscpieceid not in (select bscpieceid from bscpiece) and bscid in (select bscid from bsc) ; 

 