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.
166 lines
11 KiB
166 lines
11 KiB
USE [Vertragsverwaltung_20160404]
|
|
GO
|
|
/****** Object: StoredProcedure [dbo].[sp_ServerInventar] Script Date: 02.12.2016 09:08:53 ******/
|
|
DROP PROCEDURE [dbo].[sp_ServerInventar]
|
|
GO
|
|
/****** Object: StoredProcedure [dbo].[sp_ServerInventar] 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_ServerInventar] @fnkt INT = 0
|
|
AS
|
|
BEGIN
|
|
DECLARE @tbl TABLE
|
|
(
|
|
Mainkey INTEGER ,
|
|
Parentid INTEGER ,
|
|
bezeichnung VARCHAR(255) ,
|
|
imageindex INTEGER ,
|
|
aktiv INTEGER
|
|
)
|
|
|
|
|
|
--Root
|
|
INSERT @tbl
|
|
( Mainkey ,
|
|
Parentid ,
|
|
bezeichnung ,
|
|
imageindex ,
|
|
aktiv
|
|
)
|
|
VALUES ( 0 ,
|
|
NULL ,
|
|
'Root' ,
|
|
1 ,
|
|
1
|
|
)
|
|
|
|
--Umgebung
|
|
INSERT @tbl
|
|
( Mainkey ,
|
|
Parentid ,
|
|
bezeichnung ,
|
|
imageindex ,
|
|
aktiv
|
|
)
|
|
SELECT DISTINCT
|
|
dbo.Server_Umgebung.Server_UmgebungNr * 100000 AS MainKey ,
|
|
0 AS Parentid ,
|
|
dbo.Server_Umgebung.Bezeichnung ,
|
|
0 AS ImageIndex ,
|
|
1
|
|
FROM dbo.Server_Inventar
|
|
INNER JOIN dbo.Server_Umgebung ON dbo.Server_Inventar.Server_UmgebungNr = dbo.Server_Umgebung.Server_UmgebungNr
|
|
--WHERE server_inventar.Aktiv=1
|
|
ORDER BY MainKey
|
|
|
|
|
|
-- Server-Kategorie
|
|
INSERT @tbl
|
|
( Mainkey ,
|
|
Parentid ,
|
|
bezeichnung ,
|
|
imageindex ,
|
|
aktiv
|
|
)
|
|
SELECT DISTINCT
|
|
dbo.Server_Kategorie.Server_KategorieNr * 110000
|
|
+ dbo.Server_Inventar.Server_UmgebungNr AS MainKey ,
|
|
dbo.Server_Inventar.Server_UmgebungNr * 100000 AS ParentID ,
|
|
dbo.Server_Kategorie.Bezeichnung ,
|
|
1 AS ImageIndex ,
|
|
1
|
|
FROM dbo.Server_Inventar
|
|
INNER JOIN dbo.Server_Kategorie ON dbo.Server_Inventar.Server_KategorieNr = dbo.Server_Kategorie.Server_KategorieNr
|
|
--WHERE server_inventar.aktiv=1
|
|
|
|
|
|
|
|
IF @fnkt = 0
|
|
BEGIN
|
|
|
|
-- Server
|
|
INSERT @tbl
|
|
( Mainkey ,
|
|
Parentid ,
|
|
bezeichnung ,
|
|
imageindex ,
|
|
aktiv
|
|
)
|
|
SELECT DISTINCT
|
|
ServerInventarNr AS MainKey ,
|
|
Server_KategorieNr * 110000
|
|
+ Server_UmgebungNr AS ParentID ,
|
|
Bezeichnung ,
|
|
2 AS ImageIndex ,
|
|
AKTIV
|
|
FROM dbo.Server_Inventar
|
|
WHERE ( Aktiv = 1 )
|
|
ORDER BY Bezeichnung
|
|
END
|
|
|
|
IF @fnkt = 1
|
|
BEGIN
|
|
|
|
-- Server
|
|
INSERT @tbl
|
|
( Mainkey ,
|
|
Parentid ,
|
|
bezeichnung ,
|
|
imageindex ,
|
|
aktiv
|
|
)
|
|
SELECT DISTINCT
|
|
ServerInventarNr AS MainKey ,
|
|
Server_KategorieNr * 110000
|
|
+ Server_UmgebungNr AS ParentID ,
|
|
Bezeichnung ,
|
|
2 AS ImageIndex ,
|
|
AKTIV
|
|
FROM dbo.Server_Inventar
|
|
WHERE ( Aktiv = 0 )
|
|
ORDER BY Bezeichnung
|
|
END
|
|
|
|
IF @fnkt =2
|
|
BEGIN
|
|
|
|
-- Server
|
|
INSERT @tbl
|
|
( Mainkey ,
|
|
Parentid ,
|
|
bezeichnung ,
|
|
imageindex ,
|
|
aktiv
|
|
)
|
|
SELECT DISTINCT
|
|
ServerInventarNr AS MainKey ,
|
|
Server_KategorieNr * 110000
|
|
+ Server_UmgebungNr AS ParentID ,
|
|
Bezeichnung ,
|
|
2 AS ImageIndex ,
|
|
AKTIV
|
|
FROM dbo.Server_Inventar
|
|
|
|
ORDER BY Bezeichnung
|
|
END
|
|
|
|
UPDATE @tbl
|
|
SET imageindex = 4
|
|
WHERE aktiv = 0
|
|
SELECT *
|
|
FROM @tbl
|
|
|
|
|
|
|
|
END
|
|
|
|
|
|
GO
|