Back to OIM Explorer

dbo.QER_FTPwoValidDateRanges

Table FunctionSQL_TABLE_VALUED_FUNCTIONSandbox DB

Table Function.

Source: sandbox-db sys.sql_modules

Source size: 1.633 characters

Interpretation

  • Database function. Usually supports views, validation, or calculated predicates; look at referenced-by entries for callers.

Relations

  • No extracted relations.

Typed Edges

  • references source dbo.QBM_FTDateTimeGaps source text reference
  • references source dbo.QBM_FCVDatetimeToDatetimeEve source text reference
  • references source dbo.QBM_FCVStringToInt source text reference
  • references source dbo.QBM_FGIConfigparmValue source text reference
  • references source dbo.QER_FGIBitPatternInheritInfo source text reference

Complete Source

SQL46 lines
1CREATE FUNCTION dbo.QER_FTPwoValidDateRanges(2  @UID_PersonOrdered varchar(38),3  @UID_ITShopOrgPR varchar(38)4) RETURNS @erg TABLE(FromDatetime datetime,5UntilDatetime datetime6)7AS8BEGIN9  DECLARE @heute datetime = getutcdate()10  DECLARE @ObjectKeyAnPR varchar(138)11  DECLARE @QER_BitPatternInheritInfo int = dbo.QER_FGIBitPatternInheritInfo('|Direct|',12  0)13  DECLARE @ist QBM_YDateTimePair14  DECLARE @GapDefinition int = 015  SELECT16    @GapDefinition = dbo.QBM_FCVStringToInt(dbo.QBM_FGIConfigparmValue('QER\ITShop\GapBehavior\GapDefinition'),17    0)18  SELECT TOP 1 @ObjectKeyAnPR = bho.ObjectKey19  FROM BaseTreeHasObject bho20  WHERE21    bho.UID_Org = @UID_ITShopOrgPR AND bho.InheritInfo = @QER_BitPatternInheritInfo22  INSERT INTO @ist(FromDate,23  ToDate)24  SELECT CASE25  WHEN isnull(pwo.ValidFrom,26  '1899-12-30') < @heute THEN27  @heute28  ELSE pwo.ValidFrom29  END,30  dbo.QBM_FCVDatetimeToDatetimeEve(isnull(pwo.ValidUntil, '2200-01-01'))31  FROM PersonWantsOrg pwo32  JOIN BaseTreeHasObject bho33    ON pwo.UID_Org = bho.UID_Org AND bho.InheritInfo = @QER_BitPatternInheritInfo34  WHERE35    bho.ObjectKey = @ObjectKeyAnPR AND pwo.UID_PersonOrdered = @UID_PersonOrdered AND(pwo.Orderstate IN('Assigned',36  'Granted', 'New', 'OrderProduct', 'OrderProlongate', 'OrderUnsubscribe', 'Waiting') AND @GapDefinition = 0 OR pwo.OrderState IN('Assigned',37  'Granted', 'OrderProlongate', 'OrderUnsubscribe', 'Waiting') AND @GapDefinition = 1 OR pwo.OrderState IN('Assigned',38  'OrderProlongate', 'OrderUnsubscribe') AND @GapDefinition = 2)39  INSERT INTO @erg(FromDatetime,40  UntilDatetime)41  SELECT42    g.GapStart,43    g.GapEnd44  FROM dbo.QBM_FTDateTimeGaps(@ist) g endLabel:45  RETURN46END
Open raw exported source
SQL ยท Raw12 lines
1create function dbo.QER_FTPwoValidDateRanges(@UID_PersonOrdered varchar(38)  , @UID_ITShopOrgPR varchar(38)  ) returns @erg table(FromDatetime datetime2 , UntilDatetime datetime ) as begin declare @heute datetime = getutcdate() declare @ObjectKeyAnPR varchar(138) declare @QER_BitPatternInheritInfo int 3= dbo.QER_FGIBitPatternInheritInfo('|Direct|', 0) declare @ist QBM_YDateTimePair declare @GapDefinition int = 0 select @GapDefinition = dbo.QBM_FCVStringToInt4(dbo.QBM_FGIConfigparmValue('QER\ITShop\GapBehavior\GapDefinition'), 0) select top 1 @ObjectKeyAnPR = bho.ObjectKey from BaseTreeHasObject bho where bho.UID_Org5 = @UID_ITShopOrgPR and bho.InheritInfo = @QER_BitPatternInheritInfo insert into @ist (FromDate , ToDate) select case when isnull(pwo.ValidFrom, '1899-12-30'6) < @heute then @heute else pwo.ValidFrom end , dbo.QBM_FCVDatetimeToDatetimeEve(isnull(pwo.ValidUntil, '2200-01-01')) from PersonWantsOrg pwo join BaseTreeHasObject7 bho on pwo.UID_Org = bho.UID_Org and bho.InheritInfo = @QER_BitPatternInheritInfo where  bho.ObjectKey = @ObjectKeyAnPR and pwo.UID_PersonOrdered = @UID_PersonOrdered8        and (pwo.Orderstate in ('Assigned', 'Granted', 'New', 'OrderProduct', 'OrderProlongate', 'OrderUnsubscribe', 'Waiting') and @GapDefinition = 0 9 or pwo.OrderState in ('Assigned', 'Granted', 'OrderProlongate', 'OrderUnsubscribe', 'Waiting') and @GapDefinition = 1  or pwo.OrderState in ('Assigned'10, 'OrderProlongate', 'OrderUnsubscribe' ) and @GapDefinition = 2  ) insert into @erg(FromDatetime, UntilDatetime) select g.GapStart, g.GapEnd from dbo.QBM_FTDateTimeGaps11(@ist) g endLabel: return end 12