Anlage des Repos
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
/****** Object: UserDefinedFunction [dbo].[FNCUST_GET_PROPERTY_VALUES] Script Date: 06.10.2021 23:02:05 ******/
|
||||
SET ANSI_NULLS ON
|
||||
GO
|
||||
SET QUOTED_IDENTIFIER ON
|
||||
GO
|
||||
|
||||
-- T-SQL Tabellenfunktion zur Ermittlung von Eigenschaftswerten
|
||||
|
||||
-- Stand: MK // 06.10.2021
|
||||
-- 06.10.2021 Initial
|
||||
|
||||
ALTER FUNCTION [dbo].[FNCUST_GET_PROPERTY_VALUES] (
|
||||
@PropertyID BIGINT, -- = eg 1011 or 1012
|
||||
@ObjectID VARCHAR(200), -- = eg 10000002
|
||||
@PropertyTypeID BIGINT, -- = eg 3
|
||||
@mesocomp VARCHAR(4), -- = ToDo later....
|
||||
@mesoyear SMALLINT, -- = ToDo later....
|
||||
@ResultType VARCHAR(20) -- = ToDo later....
|
||||
)
|
||||
RETURNS @vTB_RESULT TABLE ([MESOKEY] [BIGINT] NOT NULL,
|
||||
[PROPERTY_COUNT] [BIGINT] NOT NULL,
|
||||
[PROPERTY_VALUE] [VARCHAR](max) NULL)
|
||||
AS
|
||||
BEGIN
|
||||
|
||||
DECLARE @PropertyCounter BIGINT;
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- Count how many property values were found
|
||||
SELECT @PropertyCounter = count(CountFunction.C010) FROM (
|
||||
|
||||
SELECT [CWLSYSTEM].[dbo].[t069cmp].[c010]
|
||||
|
||||
FROM [t070] (NOLOCK)
|
||||
JOIN [CWLSYSTEM].[dbo].[t069cmp] (NOLOCK) ON [t070].[c002] = [t069cmp].[C001]
|
||||
|
||||
WHERE [CWLSYSTEM].[dbo].[t069cmp].[c000] = @PropertyID
|
||||
and [CWLSYSTEM].[dbo].[t069cmp].[C003] = 0
|
||||
and [t070].[C000] = @ObjectID
|
||||
and [t070].[C003] = @PropertyTypeID
|
||||
|
||||
GROUP BY [CWLSYSTEM].[dbo].[t069cmp].[c010]
|
||||
|
||||
) as CountFunction
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
IF (@PropertyCounter >= 1)
|
||||
|
||||
BEGIN
|
||||
|
||||
INSERT INTO @vTB_RESULT ([MESOKEY],[PROPERTY_COUNT],[PROPERTY_VALUE])
|
||||
|
||||
SELECT [CWLSYSTEM].[dbo].[t069cmp].[MESOKEY],
|
||||
@PropertyCounter,
|
||||
[CWLSYSTEM].[dbo].[t069cmp].[c010]
|
||||
|
||||
FROM [t070] (NOLOCK)
|
||||
JOIN [CWLSYSTEM].[dbo].[t069cmp] (NOLOCK) ON [t070].[c002] = [t069cmp].[C001]
|
||||
|
||||
WHERE [CWLSYSTEM].[dbo].[t069cmp].[c000] = @PropertyID
|
||||
and [CWLSYSTEM].[dbo].[t069cmp].[C003] = 0
|
||||
and [t070].[C000] = @ObjectID
|
||||
and [t070].[C003] = @PropertyTypeID
|
||||
|
||||
GROUP BY [CWLSYSTEM].[dbo].[t069cmp].[mesokey],
|
||||
[CWLSYSTEM].[dbo].[t069cmp].[c010]
|
||||
|
||||
END
|
||||
|
||||
ELSE
|
||||
|
||||
BEGIN
|
||||
|
||||
INSERT INTO @vTB_RESULT ([MESOKEY],[PROPERTY_COUNT],[PROPERTY_VALUE])
|
||||
|
||||
SELECT 0, @PropertyCounter, NULL
|
||||
|
||||
END
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
RETURN;
|
||||
|
||||
END
|
||||
|
||||
Reference in New Issue
Block a user