You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ITSM/.svn/pristine/04/04dc7870e1a588539f2655559fd...

143 lines
10 KiB

USE [Vertragsverwaltung_20160404]
GO
/****** Object: StoredProcedure [dbo].[_applmig] Script Date: 02.12.2016 09:08:54 ******/
DROP PROCEDURE [dbo].[_applmig]
GO
/****** Object: StoredProcedure [dbo].[_applmig] Script Date: 02.12.2016 09:08:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[_applmig]
@debug as bit = 1,
@appl varchar(255)='alle'
AS
BEGIN
declare @applnr int
declare @bereichnr int
declare @fachoe int
declare @techoe int
declare @kategorie int
declare @rfcboard int
declare @oappl varchar(255)
declare @okat varchar(255)
declare @otechoe varchar(255)
declare @obereich varchar(255)
declare @ofachoe varchar(255)
declare @orfcboard varchar(255)
declare @error int
declare xc cursor for
select applikation,kategorie,[technische Verantwortung neu],[Bereich neu],[fachliche Verantwortung neu],[RFCBoard]
from [Vertragsverwaltung].[dbo].[__ApplMigData] where applikation=@appl or @appl='alle' order by applikation
open xc
fetch next from xc into @oappl, @okat,@otechoe,@obereich,@ofachoe,@orfcboard
while @@fetch_status=0 begin
set @error=0
set @applnr=null
set @techoe=null
set @fachoe=null
set @bereichnr=null
set @rfcboard=null
print 'Applikation: ' + @oappl
select @applnr=isnull(applikationnr,-1) from applikation where bezeichnung=@oappl
if @applnr is null begin
print '--> ' + @oappl + ' nicht vorhanden.'
set @error=1
end
--set @okat=SUBSTRING(@okat,6,len(@okat)-5)
select @kategorie=isnull(Applikationkategorienr,-1) from ApplikationKategorie where Aktiv=1 and Bezeichnung=@okat
if @kategorie is null begin
print '--> ' + @okat + ' nicht vorhanden.'
set @error=1
end
SELECT @techoe=isnull(dbo.GremiumGruppierung.GremiumGruppierungNr,-1)
FROM dbo.Gremium INNER JOIN dbo.GremiumGruppierung ON dbo.Gremium.GremiumNr = dbo.GremiumGruppierung.GremiumNr
WHERE dbo.GremiumGruppierung.Aktiv = 1 AND dbo.GremiumGruppierung.GremiumNr = 3 and dbo.GremiumGruppierung.Gruppierungsbegriff = @otechoe
if @techoe is null begin
print '--> Tech OE nicht gefunden: ' + @otechoe
set @error=1
end
SELECT @fachoe=isnull(dbo.GremiumGruppierung.GremiumGruppierungNr,-1)
FROM dbo.Gremium INNER JOIN dbo.GremiumGruppierung ON dbo.Gremium.GremiumNr = dbo.GremiumGruppierung.GremiumNr
WHERE dbo.GremiumGruppierung.Aktiv = 1 AND dbo.GremiumGruppierung.GremiumNr = 3 and dbo.GremiumGruppierung.Gruppierungsbegriff = @ofachoe
if @fachoe is null begin
print '--> Fach OE nicht gefunden: ' + @ofachoe
set @error=1
end
SELECT @bereichnr=ISNULL(dbo.GremiumGruppierung.GremiumGruppierungNr,-1)
FROM dbo.Gremium INNER JOIN
dbo.GremiumGruppierung ON dbo.Gremium.GremiumNr = dbo.GremiumGruppierung.GremiumNr
WHERE dbo.GremiumGruppierung.Aktiv = 1 AND dbo.GremiumGruppierung.GremiumNr = 4 and dbo.GremiumGruppierung.Gruppierungsbegriff = @obereich
if @bereichnr is null begin
print '--> Bereich nicht gefunden: ' + @obereich
set @error=1
end
if @orfcboard='ANL' set @rfcboard=1
if @orfcboard='FuR' set @rfcboard=4
if @orfcboard='FIN' set @rfcboard=5
if @orfcboard='IT' set @rfcboard=6
if @orfcboard='SPA' set @rfcboard=102
if @orfcboard='ZAL' set @rfcboard=103
SELECT @rfcboard=isnull(dbo.GremiumBereich.GremiumBereichNr,-1)
FROM dbo.GremiumGruppierung INNER JOIN
dbo.GremiumBereich ON dbo.GremiumGruppierung.GremiumGruppierungNr = dbo.GremiumBereich.GremiumGruppierungNr INNER JOIN
dbo.Gremium ON dbo.GremiumGruppierung.GremiumNr = dbo.Gremium.GremiumNr
WHERE dbo.Gremium.GremiumNr = 1 and gremiumbereich.aktiv=1 and dbo.GremiumBereich.Bereich=@orfcboard
if @rfcboard is null begin
print '--> RFCBoard nicht gefunden: ' + @orfcboard
set @error=1
end
if @error = 1 begin
print '- Error -'
end
print ''
if @debug=0 and @error=0 begin
update applikation set rfcboardnr=@rfcboard, applikationkategorienr=@kategorie,
applikationverantwortungnr=@techoe, fachlicheoe=@fachoe,marktbereichnr=@bereichnr
where applikationnr=@applnr
print '--> update durchgeführt'
end else begin
if @error=0 and @debug=1 begin
print '--> ' + @oappl + ' update würde durchgeführt'
end
end
fetch next from xc into @oappl, @okat,@otechoe,@obereich,@ofachoe,@orfcboard
end
close xc
deallocate xc
END
GO