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>
18 lines
705 B
Transact-SQL
18 lines
705 B
Transact-SQL
-- =============================================
|
|
-- Author: <Author,,Name>
|
|
-- Create date: <Create Date,,>
|
|
-- Description: <Description,,>
|
|
-- =============================================
|
|
CREATE FUNCTION [dbo].[fds__getRequestTreeIds]
|
|
(
|
|
@srqid bigint
|
|
)
|
|
RETURNS TABLE
|
|
AS
|
|
RETURN
|
|
(
|
|
with sp as (
|
|
SELECT DISTINCT [parentid] = CASE WHEN ISNULL([parentservicerequestid],0) = 0 THEN [id] ELSE [parentservicerequestid] END FROM [dbo].[mfr__servicerequests] as _s where _s.[Id] = @srqid OR _s.[ParentServiceRequestId] = @srqid
|
|
)
|
|
SELECT DISTINCT r.[Id] from [dbo].[mfr__servicerequests] as r JOIN sp on r.[Id] = sp.[parentid] OR r.[ParentServiceRequestId] = sp.[parentid] and ISNULL(sp.parentid,0) > 0
|
|
) |