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.
94 lines
7.3 KiB
94 lines
7.3 KiB
USE [Vertragsverwaltung_20160404]
|
|
GO
|
|
/****** Object: StoredProcedure [dbo].[sp_get_applstruktur_all] Script Date: 02.12.2016 09:08:53 ******/
|
|
DROP PROCEDURE [dbo].[sp_get_applstruktur_all]
|
|
GO
|
|
/****** Object: StoredProcedure [dbo].[sp_get_applstruktur_all] Script Date: 02.12.2016 09:08:55 ******/
|
|
SET ANSI_NULLS ON
|
|
GO
|
|
SET QUOTED_IDENTIFIER ON
|
|
GO
|
|
-- =============================================
|
|
-- Author: <Author,,Name>
|
|
-- Create date: <Create Date,,>
|
|
-- Description: <Description,,>
|
|
-- =============================================
|
|
CREATE PROCEDURE [dbo].[sp_get_applstruktur_all]
|
|
|
|
AS
|
|
|
|
BEGIN
|
|
|
|
|
|
|
|
CREATE TABLE #tmpd(
|
|
[applikationsnr] [int] ,
|
|
[bezeichnung] [varchar] (255) null,
|
|
[parentid] [int] null,
|
|
[kategorienr] [int] null,
|
|
[level] [int] null,
|
|
[TicketXPertVerwendung] bit null,
|
|
[TicketXPert_WPIAnzeigen] bit null,
|
|
[TicketXPert_Preis] varchar(255) null,
|
|
[TicketXPert_Preis_Einmalig] varchar (255) null,
|
|
[TicketXPert_AMAnzeigen] bit null,
|
|
[TicketXPert_ApplikationSMLTypNr] int null
|
|
|
|
) ON [DEFAULT]
|
|
|
|
|
|
|
|
declare @anr int
|
|
declare @anr1 int
|
|
declare xc cursor for
|
|
select applikationkategorienr from applikationkategorie order by bezeichnung
|
|
open xc
|
|
fetch next from xc into @anr
|
|
while @@FETCH_STATUS=0 begin
|
|
declare xx cursor for select applikationnr from applikation where applikationkategorienr=@anr and parentid=0 and aktiv=1 order by bezeichnung
|
|
open xx
|
|
fetch next from xx into @anr1
|
|
while @@FETCH_STATUS=0 begin
|
|
WITH DirectReports(Parentid, ApplikationNr, bezeichnung,kategorie,EmployeeLevel,
|
|
TicketXPertVerwendung,ticketxpert_wpianzeigen, TicketXPert_Preis,TicketXPert_Preis_Einmalig,
|
|
TicketXPert_AMAnzeigen,TicketXPert_ApplikationSMLTypNr) AS
|
|
(
|
|
SELECT Parentid, Applikationnr, Bezeichnung,ApplikationKategorieNr, 0 AS EmployeeLevel,
|
|
TicketXPertVerwendung,ticketxpert_wpianzeigen, TicketXPert_Preis,TicketXPert_Preis_Einmalig,
|
|
TicketXPert_AMAnzeigen,TicketXPert_ApplikationSMLTypNr
|
|
FROM Applikation
|
|
WHERE Parentid =0 and ApplikationNr=@anr1 and aktiv=1
|
|
UNION ALL
|
|
SELECT e.Parentid, e.Applikationnr, e.bezeichnung, e.ApplikationKategorieNr, EmployeeLevel + 1,
|
|
e.TicketXPertVerwendung,e.ticketxpert_wpianzeigen, e.TicketXPert_Preis,e.TicketXPert_Preis_Einmalig,
|
|
e.TicketXPert_AMAnzeigen, e.TicketXPert_ApplikationSMLTypNr
|
|
FROM Applikation e
|
|
INNER JOIN DirectReports d
|
|
ON e.ParentID = d.Applikationnr
|
|
where e.Aktiv=1
|
|
)
|
|
|
|
insert into #tmpd select Applikationnr, REPLICATE('___ ', EmployeeLevel)+bezeichnung, parentid, kategorie ,EmployeeLevel
|
|
,TicketXPertVerwendung,ticketxpert_wpianzeigen, TicketXPert_Preis,TicketXPert_Preis_Einmalig,
|
|
TicketXPert_AMAnzeigen,TicketXPert_ApplikationSMLTypNr
|
|
FROM DirectReports
|
|
fetch next from xx into @anr1
|
|
end
|
|
close xx
|
|
deallocate xx
|
|
fetch next from xc into @anr
|
|
|
|
end
|
|
close xc
|
|
deallocate xc
|
|
select #tmpd.applikationsnr, ApplikationKategorie.Bezeichnung as Kategorie, #tmpd.bezeichnung as applikation,
|
|
#tmpd.TicketXPertVerwendung,#tmpd.ticketxpert_wpianzeigen, #tmpd.TicketXPert_Preis,#tmpd.TicketXPert_Preis_Einmalig,
|
|
#tmpd.TicketXPert_AMAnzeigen, dbo.ApplikationSLMTyp.Bezeichnung as SLM
|
|
from #tmpd left outer joiN
|
|
dbo.ApplikationSLMTyp ON #tmpd.TicketXPert_ApplikationSMLTypNr = dbo.applikationslmtyp.ApplikationSLMTypNr
|
|
inner join dbo.ApplikationKategorie on #tmpd.kategorienr=dbo.ApplikationKategorie.ApplikationKategorieNr
|
|
|
|
end
|
|
|
|
GO
|