dbo.QER_FGIPwoValidDateRangesExist

SQL_SCALAR_FUNCTION

Created 2025-06-27T17:59:26.997 · modified 2026-04-14T23:17:27.300 · source: live DB sys.objects/sys.sql_expression_dependencies.

Open formatted source/search result

Parameters

NameTypeOutput
bityes
@UID_PersonOrderedvarcharno
@UID_ITShopOrgPRvarcharno
@ValidFromdatetimeno
@ValidUntildatetimeno

Referenced objects

SchemaObjectColumn/minorClass
BaseTreeAssignOBJECT_OR_COLUMN
BaseTreeHasObjectOBJECT_OR_COLUMN
DialogTableOBJECT_OR_COLUMN
PersonWantsOrgOBJECT_OR_COLUMN
QBM_YDateTimePairTYPE
QERAssignOBJECT_OR_COLUMN
dboQBM_FCVDatetimeToDatetimeEveOBJECT_OR_COLUMN
dboQBM_FCVStringToIntOBJECT_OR_COLUMN
dboQBM_FGIConfigparmValueOBJECT_OR_COLUMN
dboQBM_FGIDateTimeSpanOverlapOBJECT_OR_COLUMN
dboQBM_FTDateTimeGapsOBJECT_OR_COLUMN
dboQER_FGIBitPatternInheritInfoOBJECT_OR_COLUMN

Source excerpt

First extracted SQL definition lines from the exported source. Use the full source page for complete context.

Open full formatted source

1     create   function dbo.QER_FGIPwoValidDateRangesExist(@UID_PersonOrdered varchar(38)  , @UID_ITShopOrgPR varchar(38)  , @ValidFrom datetime 
2  , @ValidUntil datetime   ) returns bit as begin declare @wantedFrom datetime declare @wantedUntil datetime declare @erg bit = 1 declare @IsReusePossible
3 bit declare @heute datetime = getutcdate() declare @ObjectKeyAtPR varchar(138) declare @QER_BitPatternInheritInfo int = dbo.QER_FGIBitPatternInheritInfo
4('|Direct|', 0) declare @ist QBM_YDateTimePair declare @Luecke QBM_YDateTimePair declare @GapFitting int = 0 declare @GapDefinition int = 0  select @wantedFrom
5 = ISNULL(@ValidFrom, @heute) select @wantedUntil = ISNULL(@ValidUntil, '2200-01-01')  if @wantedFrom < @heute begin select @wantedFrom = @heute end if
6 @wantedUntil < @wantedFrom begin select @erg = 0 goto EndLabel end if @wantedUntil < @heute begin select @erg = 0 goto EndLabel end select top 1 @ObjectKeyAtPR
7 = bho.ObjectKey , @IsReusePossible = ((sign(len(isnull(qa.ObjectKeyAssignTarget, ''))) ^1 ) & ba.IsReusePossible) from DialogTable t with (readpast) join
8 BaseTreeAssign ba with (readpast) on ba.UID_DialogTableElement = t.UID_DialogTable join BaseTreeHasObject bho on bho.ObjectKey like '<Key><T>' + t.TableName
9 + '</T>%'  left outer join QERAssign qa on bho.ObjectKey = qa.XObjectKey where bho.UID_Org = @UID_ITShopOrgPR and bho.InheritInfo = @QER_BitPatternInheritInfo
10 if @IsReusePossible = 1 begin goto endLabel end  select @GapFitting = dbo.QBM_FCVStringToInt(dbo.QBM_FGIConfigparmValue('QER\ITShop\GapBehavior\GapFitting'
11), 0) if @GapFitting = 2  begin goto endlabel end if exists (select top 1 1 from PersonWantsOrg pwo join BaseTreeHasObject bho on pwo.UID_Org = bho.UID_Org
12 and bho.InheritInfo = @QER_BitPatternInheritInfo where  bho.ObjectKey = @ObjectKeyAtPR and pwo.UID_PersonOrdered = @UID_PersonOrdered      and pwo.OrderState
13 in ('Assigned', 'Granted', 'New', 'OrderProduct', 'OrderProlongate', 'OrderUnsubscribe', 'Waiting') ) begin  select @GapDefinition = dbo.QBM_FCVStringToInt
14(dbo.QBM_FGIConfigparmValue('QER\ITShop\GapBehavior\GapDefinition'), 0) insert into @ist (FromDate , ToDate) select case when isnull(pwo.ValidFrom, '1899-12-30'
15) < @heute then @heute else pwo.ValidFrom end , dbo.QBM_FCVDatetimeToDatetimeEve(isnull(pwo.ValidUntil, '2200-01-01')) from PersonWantsOrg pwo join BaseTreeHasObject
16 bho on pwo.UID_Org = bho.UID_Org and bho.InheritInfo = @QER_BitPatternInheritInfo where  bho.ObjectKey = @ObjectKeyAtPR and pwo.UID_PersonOrdered = @UID_PersonOrdered
17        and (pwo.OrderState in ('Assigned', 'Granted', 'New', 'OrderProduct', 'OrderProlongate', 'OrderUnsubscribe', 'Waiting') and @GapDefinition = 0 
18 or pwo.OrderState in ('Assigned', 'Granted', 'OrderProlongate', 'OrderUnsubscribe', 'Waiting') and @GapDefinition = 1  or pwo.OrderState in ('Assigned'
19, 'OrderProlongate', 'OrderUnsubscribe' ) and @GapDefinition = 2  )  insert into @Luecke(FromDate, ToDate) select g.GapStart, g.GapEnd from dbo.QBM_FTDateTimeGaps
20(@ist) g  if @ValidFrom is null and @ValidUntil is null and exists (select top 1 1 from @Luecke ) begin goto endLabel end if @GapFitting = 1  begin if 
21not exists (select top 1 1 from @Luecke l where l.FromDate <= @wantedFrom and @wantedUntil <= l.ToDate ) begin select @erg = 0 end end if @GapFitting =
22 0  begin if not exists (select top 1 1 from @Luecke l where dbo.QBM_FGIDateTimeSpanOverlap(@wantedFrom, @wantedUntil, l.FromDate, l.ToDate, 0) = 1 ) begin
23 select @erg = 0 end end    end endLabel: return (@erg) end 
24

Module relation graph

Loading module relation graph…

Source-derived context

Generated from exported SQL module definitions plus read-only sandbox sys.objects/sys.parameters/sys.sql_expression_dependencies metadata. This is factual source evidence, not a semantic guess.

provenance: SQL definition export provenance: sandbox DB metadata modified: 2026-04-14T23:17:27.300

None extracted.

Summary: writes INSERT into; reads/joins DialogTable, BaseTreeAssign, BaseTreeHasObject, QERAssign, PersonWantsOrg…; uses config QER\ITShop\GapBehavior\GapFitting, QER\ITShop\GapBehavior\GapDefinition

Declared parameters

ParameterTypeDirection
bitOUTPUT
@UID_PersonOrderedvarchar(38)input
@UID_ITShopOrgPRvarchar(38)input
@ValidFromdatetimeinput
@ValidUntildatetimeinput

DML targets

INSERT into

Called routines

None extracted.

Config/session

Config: QER\ITShop\GapBehavior\GapFitting QER\ITShop\GapBehavior\GapDefinition

Session: None extracted.

DBQueue/tasks

None extracted.

Temp tables / referenced variables

Temp: None extracted.

Variables: @UID_PersonOrdered @UID_ITShopOrgPR @ValidFrom @ValidUntil @wantedFrom @wantedUntil @erg @IsReusePossible @heute @ObjectKeyAtPR @QER_BitPatternInheritInfo @ist @Luecke @GapFitting @GapDefinition

Referenced by / reverse dependencies

Generated from live DB metadata, FK rows, and exported SQL dependency/source extraction. This is factual linkage evidence, not inferred behavior.

Referencing objectRelationEvidence
dbo.QER_FTPWOOrderPerson_000SQL expression dependencydbo · OBJECT_OR_COLUMN
dbo.QER_FTPWOOrderPerson_001SQL expression dependencydbo · OBJECT_OR_COLUMN
dbo.QER_FTPWOOrderPerson_010SQL expression dependencydbo · OBJECT_OR_COLUMN
dbo.QER_FTPWOOrderPerson_011SQL expression dependencydbo · OBJECT_OR_COLUMN
dbo.QER_FTPWOOrderPerson_100SQL expression dependencydbo · OBJECT_OR_COLUMN
dbo.QER_FTPWOOrderPerson_101SQL expression dependencydbo · OBJECT_OR_COLUMN
dbo.QER_FTPWOOrderPerson_110SQL expression dependencydbo · OBJECT_OR_COLUMN
dbo.QER_FTPWOOrderPerson_111SQL expression dependencydbo · OBJECT_OR_COLUMN