Back to OIM Explorer

dbo.TSB_PUNSAccountBInUNSGroupB1_K

Stored ProcedureSQL_STORED_PROCEDURESandbox DB

Stored Procedure.

Source: sandbox-db sys.sql_modules

Source size: 11.172 characters

Interpretation

  • Database routine. Review parameters, called procedures, DBQueue inserts, and QBM_PJobCreate helper calls before assuming side effects.

Relations

  • No extracted relations.

Typed Edges

  • references source dbo.QER_FTAccountInheritFromOrg_L source text reference
  • references source dbo.QBM_FGIBitPatternXMarkedForDel source text reference
  • references source dbo.QBM_FGIBitPatternXOrigin source text reference
  • references source dbo.QBM_FGIConfigparmValue source text reference
  • references source dbo.QBM_FGIModuleExists source text reference
  • references source dbo.TSB_FGIGroupAccountMatching source text reference
  • references source dbo.TSB_FGIUserInGroupValid source text reference
  • references source dbo.TSB_FGIUserInGroupValid_OVR source text reference
  • references source dbo.TSB_FGIUserInGroupValid_OVR_Ke source text reference
  • references source dbo.QBM_PDBQueueCalculateDelta source text reference
  • references source dbo.QBM_PSessionErrorAdd source text reference

Complete Source

SQL416 lines
1CREATE PROCEDURE TSB_PUNSAccountBInUNSGroupB1_K(2  @DBQueueCurrent QBM_YDBQueueCurrent READONLY,3  @Slotnumber int,4  @UserHasGroupList BIT,5  @CountDeltaQantity int OUTPUT,6  @CountDeltaOrigin int OUTPUT7)8AS9BEGIN10  DECLARE @PersonToCheck_L QBM_YSingleGUID11  DECLARE @UID_BaseTreeAssignToUse varchar(38) = 'TSB-AsgnBT-UNSGroupB1'12  DECLARE @Sourcedata QBM_YDataForDelta13  DECLARE @QBM_BitPatternXMarkedForDel_Delay int = dbo.QBM_FGIBitPatternXMarkedForDel('|Delay|',14  0)15  DECLARE @QBM_BitPatternXMarkedForDel_Out int = dbo.QBM_FGIBitPatternXMarkedForDel('|OutStanding|',16  0)17  DECLARE @QBM_BitPatternXOrigin_Direct int = dbo.QBM_FGIBitPatternXOrigin('|Direct|',18  0)19  DECLARE @QBM_BitPatternXOrigin_Inherit int = dbo.QBM_FGIBitPatternXOrigin('|Inherit|',20  0)21  DECLARE @QBM_BitPatternXOrigin_Inherit_inv int = dbo.QBM_FGIBitPatternXOrigin('|Inherit|',22  1)23  DECLARE @PMDKeepMembershipsOfLinkedAccount varchar(16) =24  LEFT(dbo.QBM_FGIConfigparmValue('QER\Person\User\KeepMembershipsOfLinkedAccount'),25  16)26  SET XACT_ABORT OFF27  BEGIN TRY28    INSERT INTO @PersonToCheck_L(UID_SingleGuid)29    SELECT30      DISTINCT a.UID_Person31    FROM @DBQueueCurrent cu32    JOIN UNSAccountB a33      ON cu.UID_Parameter = a.UID_UNSAccountB34    WHERE35      a.UID_Person > ' '36    IF @UserHasGroupList = 037    BEGIN38      INSERT INTO @SourceData(IsUpcommingContent,39      XOriginAfter,40      Element,41      AssignedElement,42      XOriginBefore,43      XIsInEffectBefore,44      XIsInEffectAfter)45      SELECT46        0,47        0,48        aig.UID_UNSAccountB,49        aig.UID_UNSGroupB1,50        aig.XOrigin,51        aig.XIsInEffect,52        053      FROM UNSAccountBInUNSGroupB1 aig54      JOIN @DBQueueCurrent x55        ON aig.uid_UNSAccountB = x.uid_parameter56      JOIN UNSGroupB1 g57        ON aig.UID_UNSGroupB1 = g.UID_UNSGroupB1 AND g.HasReadOnlyMemberships = 058      WHERE59        aig.XMarkedForDeletion & @QBM_BitPatternXMarkedForDel_Delay = 0 AND g.XMarkedForDeletion & @QBM_BitPatternXMarkedForDel_Out = 060      INSERT INTO @SourceData(IsUpcommingContent,61      XOriginBefore,62      XOriginAfter,63      Element,64      AssignedElement,65      XIsInEffectBefore,66      XIsInEffectAfter)67      SELECT68        1,69        0,70        aig.XOrigin & @QBM_BitPatternXOrigin_Inherit_inv,71        aig.uid_UNSAccountB,72        aig.uid_UNSGroupB1,73        0,74        dbo.TSB_FGIUserInGroupValid_OVR_Ke(p.IsInActive,75        p.IsTemporaryDeactivated,76        p.XMarkedForDeletion,77        bh.PFDInheritGroup,78        bh.PTDInheritGroup,79        bh.PMDInheritGroup,80        1,81        p.IsSecurityIncident,82        bh.PSIInheritGroup,83        n.AccountDisabled,84        bh.ADAInheritGroup,85        ovr.PFDInheritOverwrite,86        ovr.PTDInheritOverwrite,87        ovr.PSIInheritOverwrite,88        ovr.PMDInheritOverwrite,89        ovr.ADAInheritOverwrite,90        @PMDKeepMembershipsOfLinkedAccount) & CASE91        WHEN n.UID_UNSRootB = g.UID_UNSRootB THEN92        193        WHEN ns.IsExtendedInheritance = 0 THEN94        095        WHEN ns.IsExtendedInheritance = 1 AND ns.UID_DPRNameSpace = rg.UID_DPRNameSpace THEN96        197      ELSE 098      END99      FROM UNSAccountBInUNSGroupB1 aig100      JOIN @DBQueueCurrent x101        ON aig.uid_UNSAccountB = x.uid_parameter102      JOIN UNSAccountB n103        ON aig.uid_UNSAccountB = n.uid_UNSAccountB104      JOIN UNSGroupB1 g105        ON aig.UID_UNSGroupB1 = g.UID_UNSGroupB1 AND g.HasReadOnlyMemberships = 0 AND g.XMarkedForDeletion & @QBM_BitPatternXMarkedForDel_Out = 0106      JOIN UNSRootB rn107        ON n.UID_UNSRootB = rn.UID_UNSRootB108      JOIN DPRNameSpace ns109        ON rn.UID_DPRNameSpace = ns.UID_DPRNameSpace110      JOIN UNSRootB rg111        ON g.UID_UNSRootB = rg.UID_UNSRootB112      LEFT113      OUTER114      JOIN TSBSpecificGroupBehavior ovr115        ON ovr.ObjectKeyGroup = g.XObjectKey116      LEFT117      OUTER118      JOIN person p119        ON n.uid_person = p.uid_person120      LEFT121      OUTER122      JOIN TSBBehavior bh123        ON n.UID_TSBBehavior = bh.UID_TSBBehavior124    END125    ELSE126    BEGIN127      INSERT INTO @SourceData(IsUpcommingContent,128      XOriginAfter,129      Element,130      AssignedElement,131      XOriginBefore,132      XIsInEffectBefore,133      XIsInEffectAfter)134      SELECT135        0,136        0,137        aig.UID_UNSAccountB,138        aig.UID_UNSGroupB1,139        aig.XOrigin,140        aig.XIsInEffect,141        0142      FROM UNSAccountBHasUNSGroupB1 aig143      JOIN @DBQueueCurrent x144        ON aig.uid_UNSAccountB = x.uid_parameter145      JOIN UNSGroupB1 g146        ON aig.UID_UNSGroupB1 = g.UID_UNSGroupB1 AND g.HasReadOnlyMemberships = 0 AND g.XMarkedForDeletion & @QBM_BitPatternXMarkedForDel_Out = 0147      WHERE148        aig.XMarkedForDeletion & @QBM_BitPatternXMarkedForDel_Delay = 0149      INSERT INTO @SourceData(IsUpcommingContent,150      XOriginBefore,151      XOriginAfter,152      Element,153      AssignedElement,154      XIsInEffectBefore,155      XIsInEffectAfter)156      SELECT157        1,158        0,159        aig.XOrigin & @QBM_BitPatternXOrigin_Inherit_inv,160        aig.uid_UNSAccountB,161        aig.uid_UNSGroupB1,162        0,163        dbo.TSB_FGIUserInGroupValid_OVR_Ke(p.IsInActive,164        p.IsTemporaryDeactivated,165        p.XMarkedForDeletion,166        bh.PFDInheritGroup,167        bh.PTDInheritGroup,168        bh.PMDInheritGroup,169        1,170        p.IsSecurityIncident,171        bh.PSIInheritGroup,172        n.AccountDisabled,173        bh.ADAInheritGroup,174        ovr.PFDInheritOverwrite,175        ovr.PTDInheritOverwrite,176        ovr.PSIInheritOverwrite,177        ovr.PMDInheritOverwrite,178        ovr.ADAInheritOverwrite,179        @PMDKeepMembershipsOfLinkedAccount) & CASE180        WHEN n.UID_UNSRootB = g.UID_UNSRootB THEN181        1182        WHEN ns.IsExtendedInheritance = 0 THEN183        0184        WHEN ns.IsExtendedInheritance = 1 AND ns.UID_DPRNameSpace = rg.UID_DPRNameSpace THEN185        1186      ELSE 0187      END188      FROM UNSAccountBHasUNSGroupB1 aig189      JOIN @DBQueueCurrent x190        ON aig.uid_UNSAccountB = x.uid_parameter191      JOIN UNSAccountB n192        ON aig.uid_UNSAccountB = n.uid_UNSAccountB193      JOIN UNSGroupB1 g194        ON aig.UID_UNSGroupB1 = g.UID_UNSGroupB1 AND g.HasReadOnlyMemberships = 0 AND g.XMarkedForDeletion & @QBM_BitPatternXMarkedForDel_Out = 0195      JOIN UNSRootB rn196        ON n.UID_UNSRootB = rn.UID_UNSRootB197      JOIN DPRNameSpace ns198        ON rn.UID_DPRNameSpace = ns.UID_DPRNameSpace199      JOIN UNSRootB rg200        ON g.UID_UNSRootB = rg.UID_UNSRootB201      LEFT202      OUTER203      JOIN TSBSpecificGroupBehavior ovr204        ON ovr.ObjectKeyGroup = g.XObjectKey205      LEFT206      OUTER207      JOIN person p208        ON n.uid_person = p.uid_person209      LEFT210      OUTER211      JOIN TSBBehavior bh212        ON n.UID_TSBBehavior = bh.UID_TSBBehavior213    END214    INSERT INTO @SourceData(IsUpcommingContent,215    XOriginBefore,216    Element,217    AssignedElement,218    XOriginAfter,219    XIsInEffectBefore,220    XIsInEffectAfter)221    SELECT222      1,223      0,224      x.uid_UNSAccountB,225      x.uid_UNSGroupB1,226      @QBM_BitPatternXOrigin_Inherit,227      0,228      dbo.TSB_FGIUserInGroupValid_OVR_Ke(p.IsInActive,229      p.IsTemporaryDeactivated,230      p.XMarkedForDeletion,231      bh.PFDInheritGroup,232      bh.PTDInheritGroup,233      bh.PMDInheritGroup,234      0,235      p.IsSecurityIncident,236      bh.PSIInheritGroup,237      x.AccountDisabled,238      bh.ADAInheritGroup,239      ovr.PFDInheritOverwrite,240      ovr.PTDInheritOverwrite,241      ovr.PSIInheritOverwrite,242      ovr.PMDInheritOverwrite,243      ovr.ADAInheritOverwrite,244      @PMDKeepMembershipsOfLinkedAccount)245    FROM(246    SELECT247      nt.uid_UNSAccountB,248      ohg.uid_UNSGroupB1,249      nt.UID_UNSRootB,250      nt.uid_person,251      nt.AccountDisabled,252      nt.UID_TSBAccountDef,253      nt.UID_TSBBehavior,254      gg.XObjectKey255    FROM @DBQueueCurrent x256    JOIN UNSAccountB nt257      ON nt.uid_UNSAccountB = x.uid_parameter AND nt.IsGroupAccount_UNSGroupB1 = 1258    JOIN dbo.QER_FTAccountInheritFromOrg_L(@PersonToCheck_L, @UID_BaseTreeAssignToUse) pfo259      ON pfo.UID_Person = nt.UID_Person260    JOIN BaseTreeHasUNSGroupB1 ohg261      ON pfo.uid_org = ohg.uid_org AND ohg.XOrigin > 0 AND ohg.XIsInEffect = 1262    JOIN UNSGroupB1 gg263      ON ohg.uid_UNSGroupB1 = gg.uid_UNSGroupB1 AND gg.HasReadOnlyMemberships = 0 AND gg.XMarkedForDeletion & @QBM_BitPatternXMarkedForDel_Out = 0264    JOIN UNSRootB rn265      ON nt.UID_UNSRootB = rn.UID_UNSRootB266    JOIN DPRNameSpace ns267      ON rn.UID_DPRNameSpace = ns.UID_DPRNameSpace268    JOIN UNSRootB rg269      ON gg.UID_UNSRootB = rg.UID_UNSRootB270    WHERE271      dbo.TSB_FGIGroupAccountMatching(gg.MatchPatternForMembership, nt.MatchPatternForMembership) = 1 AND 1 = CASE272    WHEN nt.UID_UNSRootB = gg.UID_UNSRootB THEN273    1274    WHEN ns.IsExtendedInheritance = 0 THEN275    0276    WHEN ns.IsExtendedInheritance = 1 AND ns.UID_DPRNameSpace = rg.UID_DPRNameSpace THEN277    1278    ELSE 0279    END280    UNION all281    SELECT282      nt.uid_UNSAccountB,283      gg.uid_UNSGroupB1,284      nt.UID_UNSRootB,285      nt.uid_person,286      nt.AccountDisabled,287      nt.UID_TSBAccountDef,288      nt.UID_TSBBehavior,289      gg.XObjectKey290    FROM @DBQueueCurrent x291    JOIN UNSAccountB nt292      ON nt.uid_UNSAccountB = x.uid_parameter AND nt.IsGroupAccount_UNSGroupB1 = 1293    JOIN personHasESet phe294      ON nt.uid_person = phe.uid_person AND phe.XOrigin > 0 AND phe.XIsInEffect = 1295    JOIN person px296      ON nt.UID_Person = px.uid_person AND px.isNoInherite = 0297    JOIN ESetHasEntitlement ehe298      ON phe.uid_ESet = ehe.uid_ESet AND ehe.XOrigin > 0 AND ehe.XIsInEffect = 1 AND dbo.QBM_FGIModuleExists('RMS') = 1299    JOIN UNSGroupB1 gg300      ON ehe.Entitlement = gg.XObjectKey AND gg.HasReadOnlyMemberships = 0 AND gg.XMarkedForDeletion & @QBM_BitPatternXMarkedForDel_Out = 0301    JOIN UNSRootB rn302      ON nt.UID_UNSRootB = rn.UID_UNSRootB303    JOIN DPRNameSpace ns304      ON rn.UID_DPRNameSpace = ns.UID_DPRNameSpace305    JOIN UNSRootB rg306      ON gg.UID_UNSRootB = rg.UID_UNSRootB307    WHERE308      dbo.TSB_FGIGroupAccountMatching(gg.MatchPatternForMembership, nt.MatchPatternForMembership) = 1 AND 1 = CASE309    WHEN nt.UID_UNSRootB = gg.UID_UNSRootB THEN310    1311    WHEN ns.IsExtendedInheritance = 0 THEN312    0313    WHEN ns.IsExtendedInheritance = 1 AND ns.UID_DPRNameSpace = rg.UID_DPRNameSpace THEN314    1315    ELSE 0316    END) AS x317    JOIN UNSRootb d318      ON x.UID_UNSRootB = d.UID_UNSRootB319    LEFT320    OUTER321    JOIN person p322      ON x.uid_person = p.uid_person323    LEFT324    OUTER325    JOIN TSBBehavior bh326      ON x.UID_TSBBehavior = bh.UID_TSBBehavior327    LEFT328    OUTER329    JOIN TSBSpecificGroupBehavior ovr330      ON ovr.ObjectKeyGroup = x.XObjectKey331    WHERE332      (NOT(isnull(p.XMarkedForDeletion, 0) & @QBM_BitPatternXMarkedForDel_Delay > 0 AND bh.PMDInheritGroup IS NULL AND @PMDKeepMembershipsOfLinkedAccount333    <> 'ALL' AND ovr.PMDInheritOverwrite IS NULL))334    IF dbo.QBM_FGIConfigparmValue('QER\Structures\Inherite\GroupExclusion') > ' '335    BEGIN336      IF EXISTS(337        SELECT TOP 1 1338        FROM UNSGroupB1Exclusion ex339        WITH(nolock)340      JOIN @Sourcedata s341        ON ex.UID_UNSGroupB1Lower = s.AssignedElement342      WHERE343        s.IsUpcommingContent = 1 AND s.XOriginAfter > 0 AND s.XIsInEffectAfter = 1)344      BEGIN345        DECLARE @ExcludeCandidate QER_YExcludeCandidate346        INSERT INTO @ExcludeCandidate(Element,347        AssignedElement,348        XIsInEffectAfter)349        SELECT350          s.Element,351          s.AssignedElement,352          1353        FROM @Sourcedata s354        JOIN(355        SELECT exe.UID_UNSGroupB1Lower AS UID_Excluded356        FROM UNSGroupB1Exclusion exe) AS ex357          ON s.AssignedElement = ex.UID_Excluded358        WHERE359          s.IsUpcommingContent = 1 AND s.XOriginAfter > 0 AND s.XIsInEffectAfter = 1360        UNION all361        SELECT362          s.Element,363          s.AssignedElement,364          1365        FROM @Sourcedata s366        JOIN(367        SELECT exe.UID_UNSGroupB1Higher AS UID_Excluding368        FROM UNSGroupB1Exclusion exe) AS ex369          ON s.AssignedElement = ex.UID_Excluding370        WHERE371          s.IsUpcommingContent = 1 AND s.XOriginAfter > 0 AND s.XIsInEffectAfter = 1372        UPDATE @ExcludeCandidate373        SET XIsInEffectAfter = 0374        FROM @ExcludeCandidate l375        JOIN(376        SELECT377          exe.UID_UNSGroupB1Lower AS UID_Excluded,378          exe.UID_UNSGroupB1Higher AS UID_Excluding379        FROM UNSGroupB1Exclusion exe) AS ex380          ON l.AssignedElement = ex.UID_Excluded381        JOIN(382        SELECT sh.*383        FROM @ExcludeCandidate sh) AS h384          ON l.Element = h.Element AND h.AssignedElement = ex.UID_Excluding385        IF @@ROWCOUNT > 0386        BEGIN387          UPDATE @Sourcedata388          SET XIsInEffectAfter = 0389          FROM @Sourcedata l390          JOIN @ExcludeCandidate k391            ON l.Element = k.Element AND l.AssignedElement = k.AssignedElement AND k.XIsInEffectAfter = 0392          WHERE393            l.IsUpcommingContent = 1 AND l.XOriginAfter > 0 AND l.XIsInEffectAfter = 1394        END395      END396    END397    EXEC QBM_PDBQueueCalculateDelta @SourceData,398      @DeltaQuantity = 0,399      @DeltaDelete = 0,400      @DeltaInsert = 1,401      @DeltaOrigin = 1,402      @CountDeltaQantity = @CountDeltaQantity OUTPUT,403      @CountDeltaOrigin = @CountDeltaOrigin OUTPUT,404      @UseIsInEffect = 1,405      @SlotNumber = @SlotNumber,406      @DBQueueCurrentExtern = @DBQueueCurrent407  END TRY408  BEGIN CATCH409    EXEC QBM_PSessionErrorAdd DEFAULT410    RAISERROR('',411    18,412    1)413      WITH NOWAIT414  END CATCH415  endLabel:416END
Open raw exported source
SQL ยท Raw71 lines
1      create   procedure TSB_PUNSAccountBInUNSGroupB1_K  (@DBQueueCurrent QBM_YDBQueueCurrent readonly , @Slotnumber int , @UserHasGroupList bit2 , @CountDeltaQantity int output , @CountDeltaOrigin int output ) as begin declare @PersonToCheck_L QBM_YSingleGUID declare @UID_BaseTreeAssignToUse varchar3(38) = 'TSB-AsgnBT-UNSGroupB1' declare @Sourcedata QBM_YDataForDelta declare @QBM_BitPatternXMarkedForDel_Delay int = dbo.QBM_FGIBitPatternXMarkedForDel4('|Delay|', 0) declare @QBM_BitPatternXMarkedForDel_Out int = dbo.QBM_FGIBitPatternXMarkedForDel('|OutStanding|', 0) declare @QBM_BitPatternXOrigin_Direct5 int = dbo.QBM_FGIBitPatternXOrigin('|Direct|', 0) declare @QBM_BitPatternXOrigin_Inherit int = dbo.QBM_FGIBitPatternXOrigin('|Inherit|', 0) declare @QBM_BitPatternXOrigin_Inherit_inv6 int = dbo.QBM_FGIBitPatternXOrigin('|Inherit|', 1) declare @PMDKeepMembershipsOfLinkedAccount varchar(16) = left(dbo.QBM_FGIConfigparmValue('QER\Person\User\KeepMembershipsOfLinkedAccount'7), 16) SET XACT_ABORT OFF BEGIN TRY insert into @PersonToCheck_L(UID_SingleGuid) select distinct a.UID_Person from @DBQueueCurrent cu join UNSAccountB 8a on cu.UID_Parameter = a.UID_UNSAccountB where a.UID_Person > ' '  if @UserHasGroupList = 0 begin insert into @SourceData( IsUpcommingContent, XOriginAfter9 , Element, AssignedElement, XOriginBefore , XIsInEffectBefore, XIsInEffectAfter ) select 0, 0 , aig.UID_UNSAccountB, aig.UID_UNSGroupB1, aig.XOrigin10 , aig.XIsInEffect, 0 from UNSAccountBInUNSGroupB1 aig join @DBQueueCurrent x on aig.uid_UNSAccountB = x.uid_parameter join UNSGroupB1 g on aig.UID_UNSGroupB111 = g.UID_UNSGroupB1 and g.HasReadOnlyMemberships = 0  where aig.XMarkedForDeletion & @QBM_BitPatternXMarkedForDel_Delay = 0  and g.XMarkedForDeletion12 & @QBM_BitPatternXMarkedForDel_Out = 0  insert into @SourceData( IsUpcommingContent, XOriginBefore, XOriginAfter , Element, AssignedElement , XIsInEffectBefore13, XIsInEffectAfter ) select 1, 0, aig.XOrigin & @QBM_BitPatternXOrigin_Inherit_inv , aig.uid_UNSAccountB, aig.uid_UNSGroupB1 , 0, dbo.TSB_FGIUserInGroupValid_OVR_Ke14 ( p.IsInActive, p.IsTemporaryDeactivated, p.XMarkedForDeletion, bh.PFDInheritGroup, bh.PTDInheritGroup, bh.PMDInheritGroup, 1, p.IsSecurityIncident, bh.PSIInheritGroup15, n.AccountDisabled, bh.ADAInheritGroup , ovr.PFDInheritOverwrite, ovr.PTDInheritOverwrite, ovr.PSIInheritOverwrite, ovr.PMDInheritOverwrite, ovr.ADAInheritOverwrite16, @PMDKeepMembershipsOfLinkedAccount)  & case when n.UID_UNSRootB = g.UID_UNSRootB then 1  when ns.IsExtendedInheritance = 0 then 0 when ns.IsExtendedInheritance17 = 1 and ns.UID_DPRNameSpace = rg.UID_DPRNameSpace then 1 else 0 end  from UNSAccountBInUNSGroupB1 aig join @DBQueueCurrent x on aig.uid_UNSAccountB 18= x.uid_parameter join UNSAccountB n on aig.uid_UNSAccountB = n.uid_UNSAccountB join UNSGroupB1 g on aig.UID_UNSGroupB1 = g.UID_UNSGroupB1 and g.HasReadOnlyMemberships19 = 0   and g.XMarkedForDeletion & @QBM_BitPatternXMarkedForDel_Out = 0  join UNSRootB rn on n.UID_UNSRootB = rn.UID_UNSRootB join DPRNameSpace ns on rn.UID_DPRNameSpace20 = ns.UID_DPRNameSpace join UNSRootB rg on g.UID_UNSRootB = rg.UID_UNSRootB left outer join TSBSpecificGroupBehavior ovr on ovr.ObjectKeyGroup = g.XObjectKey21  left outer join person p on n.uid_person = p.uid_person  left outer join TSBBehavior bh on n.UID_TSBBehavior = bh.UID_TSBBehavior  end else  begin insert22 into @SourceData( IsUpcommingContent, XOriginAfter , Element, AssignedElement, XOriginBefore , XIsInEffectBefore, XIsInEffectAfter ) select 0, 0 , aig.UID_UNSAccountB23, aig.UID_UNSGroupB1, aig.XOrigin , aig.XIsInEffect, 0 from UNSAccountBHasUNSGroupB1 aig join @DBQueueCurrent x on aig.uid_UNSAccountB = x.uid_parameter24 join UNSGroupB1 g on aig.UID_UNSGroupB1 = g.UID_UNSGroupB1 and g.HasReadOnlyMemberships = 0   and g.XMarkedForDeletion & @QBM_BitPatternXMarkedForDel_Out25 = 0 where aig.XMarkedForDeletion & @QBM_BitPatternXMarkedForDel_Delay = 0  insert into @SourceData( IsUpcommingContent, XOriginBefore, XOriginAfter , 26Element, AssignedElement , XIsInEffectBefore, XIsInEffectAfter ) select 1, 0, aig.XOrigin & @QBM_BitPatternXOrigin_Inherit_inv , aig.uid_UNSAccountB, aig.uid_UNSGroupB127 , 0, dbo.TSB_FGIUserInGroupValid_OVR_Ke ( p.IsInActive, p.IsTemporaryDeactivated, p.XMarkedForDeletion, bh.PFDInheritGroup, bh.PTDInheritGroup, bh.PMDInheritGroup28, 1, p.IsSecurityIncident, bh.PSIInheritGroup, n.AccountDisabled, bh.ADAInheritGroup , ovr.PFDInheritOverwrite, ovr.PTDInheritOverwrite, ovr.PSIInheritOverwrite29, ovr.PMDInheritOverwrite, ovr.ADAInheritOverwrite, @PMDKeepMembershipsOfLinkedAccount)  & case when n.UID_UNSRootB = g.UID_UNSRootB then 1  when ns.IsExtendedInheritance30 = 0 then 0 when ns.IsExtendedInheritance = 1 and ns.UID_DPRNameSpace = rg.UID_DPRNameSpace then 1 else 0 end from UNSAccountBHasUNSGroupB1 aig join 31@DBQueueCurrent x on aig.uid_UNSAccountB = x.uid_parameter join UNSAccountB n on aig.uid_UNSAccountB = n.uid_UNSAccountB join UNSGroupB1 g on aig.UID_UNSGroupB132 = g.UID_UNSGroupB1 and g.HasReadOnlyMemberships = 0   and g.XMarkedForDeletion & @QBM_BitPatternXMarkedForDel_Out = 0  join UNSRootB rn on n.UID_UNSRootB33 = rn.UID_UNSRootB join DPRNameSpace ns on rn.UID_DPRNameSpace = ns.UID_DPRNameSpace join UNSRootB rg on g.UID_UNSRootB = rg.UID_UNSRootB left outer join34 TSBSpecificGroupBehavior ovr on ovr.ObjectKeyGroup = g.XObjectKey  left outer join person p on n.uid_person = p.uid_person left outer join TSBBehavior35 bh on n.UID_TSBBehavior = bh.UID_TSBBehavior end  insert into @SourceData( IsUpcommingContent, XOriginBefore , Element, AssignedElement, XOriginAfter 36, XIsInEffectBefore, XIsInEffectAfter ) select 1, 0 , x.uid_UNSAccountB, x.uid_UNSGroupB1, @QBM_BitPatternXOrigin_Inherit , 0, dbo.TSB_FGIUserInGroupValid_OVR_Ke37 ( p.IsInActive, p.IsTemporaryDeactivated, p.XMarkedForDeletion, bh.PFDInheritGroup, bh.PTDInheritGroup, bh.PMDInheritGroup, 0, p.IsSecurityIncident, bh.PSIInheritGroup38, x.AccountDisabled, bh.ADAInheritGroup , ovr.PFDInheritOverwrite, ovr.PTDInheritOverwrite, ovr.PSIInheritOverwrite, ovr.PMDInheritOverwrite, ovr.ADAInheritOverwrite39, @PMDKeepMembershipsOfLinkedAccount)  from (  select nt.uid_UNSAccountB , ohg.uid_UNSGroupB1 , nt.UID_UNSRootB , nt.uid_person, nt.AccountDisabled ,40 nt.UID_TSBAccountDef, nt.UID_TSBBehavior, gg.XObjectKey from @DBQueueCurrent x join UNSAccountB nt on nt.uid_UNSAccountB = x.uid_parameter   and nt.IsGroupAccount_UNSGroupB141 = 1 join dbo.QER_FTAccountInheritFromOrg_L(@PersonToCheck_L , @UID_BaseTreeAssignToUse ) pfo on pfo.UID_Person = nt.UID_Person join BaseTreeHasUNSGroupB142 ohg on pfo.uid_org = ohg.uid_org and ohg.XOrigin > 0 and ohg.XIsInEffect = 1 join UNSGroupB1 gg on ohg.uid_UNSGroupB1 = gg.uid_UNSGroupB1 and gg.HasReadOnlyMemberships43 = 0   and gg.XMarkedForDeletion & @QBM_BitPatternXMarkedForDel_Out = 0  join UNSRootB rn on nt.UID_UNSRootB = rn.UID_UNSRootB join DPRNameSpace ns on 44rn.UID_DPRNameSpace = ns.UID_DPRNameSpace join UNSRootB rg on gg.UID_UNSRootB = rg.UID_UNSRootB  where dbo.TSB_FGIGroupAccountMatching( gg.MatchPatternForMembership45, nt.MatchPatternForMembership) = 1 and 1 = case when nt.UID_UNSRootB = gg.UID_UNSRootB then 1  when ns.IsExtendedInheritance = 0 then 0 when ns.IsExtendedInheritance46 = 1 and ns.UID_DPRNameSpace = rg.UID_DPRNameSpace then 1 else 0 end union all  select nt.uid_UNSAccountB , gg.uid_UNSGroupB1 , nt.UID_UNSRootB , nt.uid_person47 , nt.AccountDisabled , nt.UID_TSBAccountDef , nt.UID_TSBBehavior , gg.XObjectKey from @DBQueueCurrent x join UNSAccountB nt on nt.uid_UNSAccountB = x.uid_parameter48  and nt.IsGroupAccount_UNSGroupB1 = 1 join personHasESet phe on nt.uid_person = phe.uid_person and phe.XOrigin > 0 and phe.XIsInEffect = 1  join person49 px on nt.UID_Person = px.uid_person and px.isNoInherite = 0  join ESetHasEntitlement ehe on phe.uid_ESet = ehe.uid_ESet and ehe.XOrigin > 0 and ehe.XIsInEffect50 = 1 and dbo.QBM_FGIModuleExists('RMS') = 1 join UNSGroupB1 gg on ehe.Entitlement = gg.XObjectKey and gg.HasReadOnlyMemberships = 0   and gg.XMarkedForDeletion51 & @QBM_BitPatternXMarkedForDel_Out = 0  join UNSRootB rn on nt.UID_UNSRootB = rn.UID_UNSRootB join DPRNameSpace ns on rn.UID_DPRNameSpace = ns.UID_DPRNameSpace52 join UNSRootB rg on gg.UID_UNSRootB = rg.UID_UNSRootB where dbo.TSB_FGIGroupAccountMatching( gg.MatchPatternForMembership, nt.MatchPatternForMembership53) = 1 and 1 = case when nt.UID_UNSRootB = gg.UID_UNSRootB then 1  when ns.IsExtendedInheritance = 0 then 0 when ns.IsExtendedInheritance = 1 and ns.UID_DPRNameSpace54 = rg.UID_DPRNameSpace then 1 else 0 end ) as x join UNSRootb d on x.UID_UNSRootB = d.UID_UNSRootB left outer join person p on x.uid_person = p.uid_person55  left outer join TSBBehavior bh on x.UID_TSBBehavior = bh.UID_TSBBehavior  left outer join TSBSpecificGroupBehavior ovr on ovr.ObjectKeyGroup = x.XObjectKey56   where (not (isnull(p.XMarkedForDeletion, 0) & @QBM_BitPatternXMarkedForDel_Delay > 0 and bh.PMDInheritGroup is null and @PMDKeepMembershipsOfLinkedAccount57 <> 'ALL' and ovr.PMDInheritOverwrite is null ) )  if dbo.QBM_FGIConfigparmValue('QER\Structures\Inherite\GroupExclusion') > ' ' begin if exists (select58 top 1 1 from UNSGroupB1Exclusion ex with (nolock) join @Sourcedata s on ex.UID_UNSGroupB1Lower  = s.AssignedElement where s.IsUpcommingContent = 159 and s.XOriginAfter > 0 and s.XIsInEffectAfter = 1 ) begin declare @ExcludeCandidate QER_YExcludeCandidate insert into @ExcludeCandidate(Element, AssignedElement60, XIsInEffectAfter) select s.Element, s.AssignedElement, 1 from @Sourcedata s join ( select exe.UID_UNSGroupB1Lower as UID_Excluded from UNSGroupB1Exclusion61 exe ) as ex on s.AssignedElement = ex.UID_Excluded where s.IsUpcommingContent = 1 and s.XOriginAfter > 0 and s.XIsInEffectAfter = 1 union all select s.Element62, s.AssignedElement, 1 from @Sourcedata s join ( select exe.UID_UNSGroupB1Higher as UID_Excluding from UNSGroupB1Exclusion exe ) as ex on s.AssignedElement63 = ex.UID_Excluding where s.IsUpcommingContent = 1 and s.XOriginAfter > 0 and s.XIsInEffectAfter = 1 update @ExcludeCandidate set XIsInEffectAfter = 0 64from @ExcludeCandidate l  join ( select exe.UID_UNSGroupB1Lower as UID_Excluded, exe.UID_UNSGroupB1Higher as UID_Excluding from UNSGroupB1Exclusion65 exe ) as ex on l.AssignedElement = ex.UID_Excluded join (select sh.* from @ExcludeCandidate sh  ) as h on l.Element = h.Element and h.AssignedElement 66= ex.UID_Excluding if @@ROWCOUNT > 0 begin update @Sourcedata set XIsInEffectAfter = 0 from @Sourcedata l join @ExcludeCandidate k on l.Element = k.Element67 and l.AssignedElement = k.AssignedElement and k.XIsInEffectAfter = 0 where l.IsUpcommingContent = 1 and l.XOriginAfter > 0 and l.XIsInEffectAfter = 1 68end end  end   exec QBM_PDBQueueCalculateDelta @SourceData, @DeltaQuantity = 0, @DeltaDelete = 0, @DeltaInsert = 1, @DeltaOrigin = 1, @CountDeltaQantity69 = @CountDeltaQantity output , @CountDeltaOrigin = @CountDeltaOrigin output , @UseIsInEffect = 1 , @SlotNumber = @SlotNumber , @DBQueueCurrentExtern = 70@DBQueueCurrent END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default RAISERROR ('', 18, 1) WITH NOWAIT END CATCH endLabel: end 71