10ecdfa2e4
Adds the SQL Server Data Tools project for the fuchs_fds database — tables, table types, functions and stored procedures that the backend calls (e.g. fds__getInvoice, fds__merge_bankingtransactions, fds__tt__bankingtransactions, fds__admin_getReportCatalog, fis_* auth). Build/model caches (bin, obj, *.dbmdl, *.jfm, *.user) are git-ignored. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
52 lines
1.3 KiB
Transact-SQL
52 lines
1.3 KiB
Transact-SQL
|
|
-- =============================================
|
|
-- Author: <Author,,Name>
|
|
-- Create date: <Create Date, ,>
|
|
-- Description: <Description, ,>
|
|
-- =============================================
|
|
CREATE FUNCTION [dbo].[ott_jcsv_contains]
|
|
(
|
|
@groupcode varchar(10)
|
|
,@text varchar(4000)
|
|
,@fragment varchar(500)
|
|
)
|
|
RETURNS bit
|
|
AS
|
|
BEGIN
|
|
DECLARE @RET bit;
|
|
DECLARE @textinput varchar(4000) = REPLACE(ISNULL(@text, ''), ' ', '');
|
|
|
|
IF (@textinput = '' OR @textinput = '{}' OR @fragment = '')
|
|
BEGIN
|
|
SET @RET = 0;
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
|
|
-- Will be true
|
|
-- if any of the fragments exist in the list of text-items
|
|
|
|
DECLARE @Pattern varchar(20) = '%"' + @groupcode + '":"%';
|
|
DECLARE @P0 int = PATINDEX(@pattern, @textinput);
|
|
DECLARE @P1 int = @P0 + LEN(@pattern) -2;
|
|
DECLARE @P2 int = CHARINDEX('"',@textinput,@p1);
|
|
|
|
IF @P0 = 0
|
|
BEGIN
|
|
SET @RET = 0;
|
|
|
|
END
|
|
ELSE
|
|
BEGIN
|
|
DECLARE @text2 varchar(4000) = SUBSTRING(@textinput, @P1, @P2 - @P1);
|
|
|
|
WITH texts as (SELECT * FROM string_split(ISNULL(@text2,''), ','))
|
|
,fragments as (SELECT * FROM string_split(ISNULL(@fragment,''), ','))
|
|
SELECT @RET = CASE WHEN EXISTS (SELECT * FROM texts JOIN fragments ON texts.[value] = fragments.[value]) THEN 1 ELSE 0 END;
|
|
END
|
|
|
|
END
|
|
|
|
RETURN @RET;
|
|
|
|
END |