Back to OIM Explorer

dbo.QER_ZITShopDecisionMakerFill

Stored ProcedureSQL_STORED_PROCEDURESandbox DB

Stored Procedure.

Source: sandbox-db sys.sql_modules

Source size: 10.666 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.QBM_FGISessionContext source text reference
  • references source dbo.QER_FCVRuleGUIDToFunctionName source text reference
  • references source dbo.QBM_PExecuteSQLWithRetry_LLP source text reference
  • references source dbo.QBM_PSessionContextSet source text reference
  • references source dbo.QBM_PSessionErrorAdd source text reference

Complete Source

SQL432 lines
1CREATE PROCEDURE QER_ZITShopDecisionMakerFill(2  @SlotNumberDummy int,3  @dummy1 varchar(38),4  @dummy2 varchar(38),5  @GenProcIDDummy varchar(38)6)7AS8BEGIN9  DECLARE @AfterAlle QBM_YDBQueueRaw10  DECLARE @AfterKomplett QBM_YSingleGUID11  DECLARE @alleRegeln QBM_YSingleGUID12  DECLARE @SQLTest nvarchar(max) = ''13  DECLARE @GenProcID varchar(38) = newid()14  DECLARE @GenProcID_R varchar(38) = dbo.QBM_FGISessionContext('')15  DECLARE @DebugSwitch int = 016  BEGIN TRY17    INSERT INTO @alleRegeln(UID_SingleGuid)18    SELECT s.uid_PWODecisionRule19    FROM BaseTree b20    JOIN pwodecisionmethod m21      ON b.uid_pwoDecisionMethod = m.uid_pwodecisionMethod22    JOIN pwodecisionstep s23      ON m.UID_SubMethodOrderProduct = s.UID_PWODecisionSubMethod24    UNION25    SELECT s.uid_PWODecisionRule26    FROM BaseTree b27    JOIN pwodecisionmethod m28      ON b.uid_pwoDecisionMethod = m.uid_pwodecisionMethod29    JOIN pwodecisionstep s30      ON m.UID_SubMethodOrderUnsubscribe = s.UID_PWODecisionSubMethod31    UNION32    SELECT s.uid_PWODecisionRule33    FROM BaseTree b34    JOIN pwodecisionmethod m35      ON b.uid_pwoDecisionMethod = m.uid_pwodecisionMethod36    JOIN pwodecisionstep s37      ON m.UID_SubMethodOrderProlongate = s.UID_PWODecisionSubMethod38    INSERT INTO @AfterAlle(Object)39    SELECT pio.UID_Person40    FROM PWODecisionStep s41    JOIN BaseTree b42      ON s.ObjectKeyOfAssignedOrg = b.XObjectKey43    JOIN PersonInBaseTree pio44      ON b.UID_Org = pio.UID_Org AND pio.XOrigin > 045    WHERE46      s.usagearea = 'I'47    SELECT48      @SQLTest = string_agg(CONCAT(convert(nvarchar(max), N ''), 'select uid_person 49			from dbo.', rtrim(o.name),50      '(null, null)'),51      '52		union53		')54    FROM sys.objects o55    WHERE56      o.name IN(57    SELECT dbo.QER_FCVRuleGUIDToFunctionName(r.UID_PWODecisionRule)58    FROM PWODecisionRule r59    WHERE60      r.usagearea = 'I') AND NOT EXISTS(61    SELECT TOP 1 162    FROM sys.sql_modules m63    WHERE64      m.object_id = o.object_id AND(charindex('@uid_PersonWantsOrg',65    LEFT(m.definition, 8000)) > 0 OR charindex('@UID_QERWorkingStep',66    LEFT(m.definition, 8000)) > 0))67    IF @DebugSwitch > 068    BEGIN69      print @SQLTest70    END71    INSERT INTO @AfterAlle(Object)72    EXEC QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLTest,73      @LockTimeout_ms = DEFAULT,74      @MaxWaitTimeForLock_s = 4.0,75      @ProcIDForJournal = @@PROCID,76      @HandleErrorSilent = 077    IF EXISTS(78      SELECT TOP 1 179      FROM @alleRegeln s80      WHERE81        s.UID_SingleGuid = 'QER-PWODecisionRule-D0')82    BEGIN83      INSERT INTO @AfterAlle(Object)84      SELECT hho.uid_personHead85      FROM BaseTree bo86      JOIN helperheadOrg hho87        ON BO.UID_OrgDepartment = hho.uid_org AND hho.XOrigin > 0 AND bo.ITShopInfo = 'BO' AND bo.uid_OrgRoot = 'QER-V-ITShopOrg'88    END89    IF EXISTS(90      SELECT TOP 1 191      FROM @alleRegeln s92      WHERE93        s.UID_SingleGuid = 'QER-PWODecisionRule-D1')94    BEGIN95      INSERT INTO @AfterAlle(Object)96      SELECT97        DISTINCT hho.uid_personHead98      FROM BaseTree bo99      JOIN helperHeadOrg hho100        ON BO.UID_OrgDepartment = hho.uid_org AND hho.XOrigin > 0 AND bo.ITShopInfo = 'SH' AND bo.uid_OrgRoot = 'QER-V-ITShopOrg'101    END102    IF EXISTS(103      SELECT TOP 1 1104      FROM @alleRegeln s105      WHERE106        s.UID_SingleGuid = 'QER-PWODecisionRule-D2')107    BEGIN108      INSERT INTO @AfterAlle(Object)109      SELECT110        DISTINCT hho.uid_personHead111      FROM BaseTree bo112      JOIN helperHeadOrg hho113        ON BO.UID_OrgDepartment = hho.uid_org AND hho.XOrigin > 0 AND bo.ITShopInfo = 'SC' AND bo.uid_OrgRoot = 'QER-V-ITShopOrg'114    END115    IF EXISTS(116      SELECT TOP 1 1117      FROM @alleRegeln s118      WHERE119        s.UID_SingleGuid = 'QER-PWODecisionRule-P0')120    BEGIN121      INSERT INTO @AfterAlle(Object)122      SELECT123        DISTINCT hho.uid_personHead124      FROM BaseTree bo125      JOIN helperHeadOrg hho126        ON BO.UID_OrgProfitCenter = hho.uid_org AND hho.XOrigin > 0 AND bo.ITShopInfo = 'BO' AND bo.uid_OrgRoot = 'QER-V-ITShopOrg'127    END128    IF EXISTS(129      SELECT TOP 1 1130      FROM @alleRegeln s131      WHERE132        s.UID_SingleGuid = 'QER-PWODecisionRule-P1')133    BEGIN134      INSERT INTO @AfterAlle(Object)135      SELECT136        DISTINCT hho.uid_personHead137      FROM BaseTree bo138      JOIN helperHeadOrg hho139        ON BO.UID_OrgProfitCenter = hho.uid_org AND hho.XOrigin > 0 AND bo.ITShopInfo = 'SH' AND bo.uid_OrgRoot = 'QER-V-ITShopOrg'140    END141    IF EXISTS(142      SELECT TOP 1 1143      FROM @alleRegeln s144      WHERE145        s.UID_SingleGuid = 'QER-PWODecisionRule-P2')146    BEGIN147      INSERT INTO @AfterAlle(Object)148      SELECT149        DISTINCT hho.uid_personHead150      FROM BaseTree bo151      JOIN helperHeadOrg hho152        ON BO.UID_OrgProfitCenter = hho.uid_org AND hho.XOrigin > 0 AND bo.ITShopInfo = 'SC' AND bo.uid_OrgRoot = 'QER-V-ITShopOrg'153    END154    IF EXISTS(155      SELECT TOP 1 1156      FROM @alleRegeln s157      WHERE158        s.UID_SingleGuid = 'QER-PWODecisionRule-H0')159    BEGIN160      INSERT INTO @AfterAlle(Object)161      SELECT162        DISTINCT hho.uid_PersonHead163      FROM BaseTree b164      JOIN helperHeadOrg hho165        ON b.uid_Org = hho.uid_org AND hho.XOrigin > 0166      WHERE167        b.ITShopInfo = 'BO' AND b.uid_OrgRoot = 'QER-V-ITShopOrg'168    END169    IF EXISTS(170      SELECT TOP 1 1171      FROM @alleRegeln s172      WHERE173        s.UID_SingleGuid = 'QER-PWODecisionRule-H1')174    BEGIN175      INSERT INTO @AfterAlle(Object)176      SELECT177        DISTINCT hho.uid_PersonHead178      FROM BaseTree b179      JOIN helperHeadOrg hho180        ON b.uid_Org = hho.uid_org AND hho.XOrigin > 0181      WHERE182        b.ITShopInfo = 'SH' AND b.uid_OrgRoot = 'QER-V-ITShopOrg'183    END184    IF EXISTS(185      SELECT TOP 1 1186      FROM @alleRegeln s187      WHERE188        s.UID_SingleGuid = 'QER-PWODecisionRule-H2')189    BEGIN190      INSERT INTO @AfterAlle(Object)191      SELECT192        DISTINCT hho.uid_PersonHead193      FROM BaseTree b194      JOIN helperHeadOrg hho195        ON b.uid_org = hho.uid_org AND hho.XOrigin > 0196      WHERE197        b.ITShopInfo = 'SC' AND b.uid_OrgRoot = 'QER-V-ITShopOrg'198    END199    IF EXISTS(200      SELECT TOP 1 1201      FROM @alleRegeln s202      WHERE203        s.UID_SingleGuid = 'QER-PWODecisionRule-DM')204    BEGIN205      INSERT INTO @AfterAlle(Object)206      SELECT207        DISTINCT hho.uid_personHead208      FROM BaseTree d209      JOIN helperHeadOrg hho210        ON d.uid_org = hho.uid_Org AND hho.XOrigin > 0 AND d.uid_orgroot = 'QER-V-Department'211    END212    IF EXISTS(213      SELECT TOP 1 1214      FROM @alleRegeln s215      WHERE216        s.UID_SingleGuid = 'QER-PWODecisionRule-PM')217    BEGIN218      INSERT INTO @AfterAlle(Object)219      SELECT220        DISTINCT hho.uid_personHead221      FROM ProfitCenter p222      JOIN helperHeadOrg hho223        ON p.uid_ProfitCenter = hho.uid_org AND hho.XOrigin > 0224    END225    IF EXISTS(226      SELECT TOP 1 1227      FROM @alleRegeln s228      WHERE229        s.UID_SingleGuid = 'QER-PWODecisionRule-CM')230    BEGIN231      INSERT INTO @AfterAlle(Object)232      SELECT233        DISTINCT uid_personHead234      FROM helperHeadPerson235      WHERE236        XOrigin > 0237    END238    IF EXISTS(239      SELECT TOP 1 1240      FROM @alleRegeln s241      WHERE242        s.UID_SingleGuid = 'QER-PWODecisionRule-PP')243    BEGIN244      INSERT INTO @AfterAlle(Object)245      SELECT246        DISTINCT hho.uid_personHead247      FROM BaseTree pr248      JOIN helperHeadOrg hho249        ON pr.UID_Org = hho.uid_org AND hho.XOrigin > 0 AND pr.UID_OrgRoot = 'QER-V-ProfitCenter'250    END251    IF EXISTS(252      SELECT TOP 1 1253      FROM @alleRegeln s254      WHERE255        s.UID_SingleGuid = 'QER-PWODecisionRule-DP')256    BEGIN257      INSERT INTO @AfterAlle(Object)258      SELECT259        DISTINCT hho.uid_personHead260      FROM BaseTree pr261      JOIN helperHeadOrg hho262        ON pr.UID_Org = hho.uid_org AND hho.XOrigin > 0 AND pr.uid_orgroot = 'QER-V-Department'263    END264    IF EXISTS(265      SELECT TOP 1 1266      FROM @alleRegeln s267      WHERE268        s.UID_SingleGuid IN('QER-PWODecisionRule-PR', 'QER-PWODecisionRule-RP'))269    BEGIN270      INSERT INTO @AfterAlle(Object)271      SELECT272        DISTINCT pib.uid_person273      FROM BaseTree pr274      JOIN personinBaseTree pib275        ON pr.UID_RulerContainer = pib.uid_org AND pr.UID_OrgRoot = 'QER-V-ProfitCenter' AND pib.XOrigin > 0276    END277    IF EXISTS(278      SELECT TOP 1 1279      FROM @alleRegeln s280      WHERE281        s.UID_SingleGuid IN('QER-PWODecisionRule-PI', 'QER-PWODecisionRule-IP'))282    BEGIN283      INSERT INTO @AfterAlle(Object)284      SELECT285        DISTINCT pib.uid_person286      FROM BaseTree pr287      JOIN personinBaseTree pib288        ON pr.UID_RulerContainerIT = pib.uid_org AND pr.UID_OrgRoot = 'QER-V-ProfitCenter' AND pib.XOrigin > 0289    END290    IF EXISTS(291      SELECT TOP 1 1292      FROM @alleRegeln s293      WHERE294        s.UID_SingleGuid IN('QER-PWODecisionRule-DR', 'QER-PWODecisionRule-RD'))295    BEGIN296      INSERT INTO @AfterAlle(Object)297      SELECT298        DISTINCT pib.uid_person299      FROM BaseTree pr300      JOIN personinBaseTree pib301        ON pr.UID_RulerContainer = pib.uid_org AND pr.uid_orgroot = 'QER-V-Department' AND pib.XOrigin > 0302    END303    IF EXISTS(304      SELECT TOP 1 1305      FROM @alleRegeln s306      WHERE307        s.UID_SingleGuid IN('QER-PWODecisionRule-DI', 'QER-PWODecisionRule-ID'))308    BEGIN309      INSERT INTO @AfterAlle(Object)310      SELECT311        DISTINCT pib.uid_person312      FROM BaseTree pr313      JOIN personinBaseTree pib314        ON pr.UID_RulerContainerIT = pib.uid_org AND pr.uid_orgroot = 'QER-V-Department' AND pib.XOrigin > 0315    END316    IF EXISTS(317      SELECT TOP 1 1318      FROM @alleRegeln s319      WHERE320        s.UID_SingleGuid = 'QER-PWODecisionRule-IL')321    BEGIN322      INSERT INTO @AfterAlle(Object)323      SELECT324        DISTINCT pib.uid_person325      FROM BaseTree pr326      JOIN personinBaseTree pib327        ON pr.UID_RulerContainerIT = pib.uid_org AND pr.UID_OrgRoot = 'QER-V-Locality' AND pib.XOrigin > 0328    END329    IF EXISTS(330      SELECT TOP 1 1331      FROM @alleRegeln s332      WHERE333        s.UID_SingleGuid = 'QER-PWODecisionRule-RL')334    BEGIN335      INSERT INTO @AfterAlle(Object)336      SELECT337        DISTINCT pib.uid_person338      FROM BaseTree pr339      JOIN personinBaseTree pib340        ON pr.UID_RulerContainer = pib.uid_org AND pr.UID_OrgRoot = 'QER-V-Locality' AND pib.XOrigin > 0341    END342    IF EXISTS(343      SELECT TOP 1 1344      FROM @alleRegeln s345      WHERE346        s.UID_SingleGuid = 'RMB-PWODecisionRule-IO')347    BEGIN348      INSERT INTO @AfterAlle(Object)349      SELECT350        DISTINCT pib.uid_person351      FROM BaseTree pr352      JOIN personinBaseTree pib353        ON pr.UID_RulerContainerIT = pib.uid_org AND pr.UID_OrgRoot LIKE '____[^V]%' AND pib.XOrigin > 0354    END355    IF EXISTS(356      SELECT TOP 1 1357      FROM @alleRegeln s358      WHERE359        s.UID_SingleGuid = 'RMB-PWODecisionRule-RO')360    BEGIN361      INSERT INTO @AfterAlle(Object)362      SELECT363        DISTINCT pib.uid_person364      FROM BaseTree pr365      JOIN personinBaseTree pib366        ON pr.UID_RulerContainer = pib.uid_org AND pr.UID_OrgRoot LIKE '____[^V]%' AND pib.XOrigin > 0367    END368    IF EXISTS(369      SELECT TOP 1 1370      FROM @alleRegeln s371      WHERE372        s.UID_SingleGuid = 'QER-PWODecisionRule-OA')373    BEGIN374      INSERT INTO @AfterAlle(Object)375      SELECT pio.uid_person376      FROM personinBaseTree pio377      JOIN accproduct a378        ON pio.uid_org = a.uid_orgruler AND pio.XOrigin > 0379      GROUP BY pio.uid_person380    END381    IF EXISTS(382      SELECT TOP 1 1383      FROM @alleRegeln s384      WHERE385        s.UID_SingleGuid IN('CPL-PWODecisionRule-OC', 'CPL-PWODecisionRule-OH'))386    BEGIN387      INSERT INTO @AfterAlle(Object)388      SELECT389        DISTINCT pio.uid_person390      FROM personinBaseTree pio391      JOIN compliancerule cr392        ON cr.uid_orgruler = pio.uid_org AND pio.XOrigin > 0393      WHERE394        cr.isinactive=0 AND cr.isexceptionallowed=1 AND cr.isworkingcopy=0395    END396    INSERT INTO @AfterKomplett(UID_SingleGuid)397    SELECT398      DISTINCT Object399    FROM @AfterAlle a400    WHERE401      a.Object > ' '402    EXEC QBM_PSessionContextSet 'GenProcID',403      @GenProcID404    DELETE pwoHelperDecisionMaker405    WHERE406      NOT EXISTS(407    SELECT TOP 1 1408    FROM @AfterKomplett t409    WHERE410      t.UID_SingleGuid = pwoHelperDecisionMaker.uid_personhead)411    INSERT INTO pwoHelperDecisionMaker(uid_personHead)412    SELECT t.UID_SingleGuid413    FROM @AfterKomplett t414    WHERE415      NOT EXISTS(416    SELECT TOP 1 1417    FROM pwoHelperDecisionMaker m418    WHERE419      m.uid_personhead = t.UID_SingleGuid)420  END TRY421  BEGIN CATCH422    EXEC QBM_PSessionErrorAdd DEFAULT423    RAISERROR('',424    18,425    1)426      WITH NOWAIT427  END CATCH428  ende:429  EXEC QBM_PSessionContextSet 'GenProcID',430    @GenProcID_R431  RETURN432END
Open raw exported source
SQL ยท Raw72 lines
1       create   procedure QER_ZITShopDecisionMakerFill (@SlotNumberDummy int , @dummy1 varchar(38) , @dummy2 varchar(38) , @GenProcIDDummy varchar2(38) ) as begin   declare @AfterAlle QBM_YDBQueueRaw  declare @AfterKomplett QBM_YSingleGUID  declare @alleRegeln QBM_YSingleGUID  declare @SQLTest nvarchar3(max) = '' declare @GenProcID varchar(38) = newid() declare @GenProcID_R varchar(38) = dbo.QBM_FGISessionContext('') declare @DebugSwitch int = 0 BEGIN4 TRY insert into @alleRegeln(UID_SingleGuid ) select s.uid_PWODecisionRule from BaseTree b join pwodecisionmethod m on b.uid_pwoDecisionMethod = m.uid_pwodecisionMethod5 join pwodecisionstep s on m.UID_SubMethodOrderProduct = s.UID_PWODecisionSubMethod union select s.uid_PWODecisionRule from BaseTree b join pwodecisionmethod6 m on b.uid_pwoDecisionMethod = m.uid_pwodecisionMethod join pwodecisionstep s on m.UID_SubMethodOrderUnsubscribe = s.UID_PWODecisionSubMethod union select7 s.uid_PWODecisionRule from BaseTree b join pwodecisionmethod m on b.uid_pwoDecisionMethod = m.uid_pwodecisionMethod join pwodecisionstep s on m.UID_SubMethodOrderProlongate8 = s.UID_PWODecisionSubMethod insert into @AfterAlle (Object ) select pio.UID_Person from PWODecisionStep s join BaseTree b on s.ObjectKeyOfAssignedOrg9 = b.XObjectKey join PersonInBaseTree pio on b.UID_Org = pio.UID_Org and pio.XOrigin > 0 where s.usagearea = 'I'   select @SQLTest = string_agg( concat10(convert(nvarchar(max), N''), 'select uid_person 11			from dbo.' , rtrim(o.name) , '(null, null)' )  , '12		union13		' )  from sys.objects o where o.name14 in (select dbo.QER_FCVRuleGUIDToFunctionName(r.UID_PWODecisionRule) from PWODecisionRule r where r.usagearea = 'I' ) and Not exists (select top 1 1 from15 sys.sql_modules m where m.object_id = o.object_id and ( charindex('@uid_PersonWantsOrg', left(m.definition, 8000)) > 0  or charindex('@UID_QERWorkingStep'16, left(m.definition, 8000)) > 0 ) ) if @DebugSwitch > 0 begin print @SQLTest end  insert into @AfterAlle (Object ) exec QBM_PExecuteSQLWithRetry_LLP @SQLStatement17 = @SQLTest , @LockTimeout_ms = default , @MaxWaitTimeForLock_s = 4.0 , @ProcIDForJournal = @@PROCID , @HandleErrorSilent = 0   if exists (select top 118 1 from @alleRegeln s where s.UID_SingleGuid  = 'QER-PWODecisionRule-D0') begin insert into @AfterAlle (Object ) select hho.uid_personHead from BaseTree19 bo join helperheadOrg hho on BO.UID_OrgDepartment = hho.uid_org and hho.XOrigin > 0 and bo.ITShopInfo = 'BO' and bo.uid_OrgRoot = 'QER-V-ITShopOrg' end20 if exists (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  = 'QER-PWODecisionRule-D1') begin insert into @AfterAlle (Object ) select distinct21 hho.uid_personHead from BaseTree bo join helperHeadOrg hho on BO.UID_OrgDepartment = hho.uid_org and hho.XOrigin > 0 and bo.ITShopInfo = 'SH' and bo.uid_OrgRoot22 = 'QER-V-ITShopOrg' end if exists (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  = 'QER-PWODecisionRule-D2') begin insert into @AfterAlle 23(Object ) select distinct hho.uid_personHead from BaseTree bo join helperHeadOrg hho on BO.UID_OrgDepartment = hho.uid_org and hho.XOrigin > 0 and bo.ITShopInfo24 = 'SC' and bo.uid_OrgRoot = 'QER-V-ITShopOrg' end if exists (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  = 'QER-PWODecisionRule-P0') begin25 insert into @AfterAlle (Object ) select distinct hho.uid_personHead from BaseTree bo join helperHeadOrg hho on BO.UID_OrgProfitCenter = hho.uid_org and26 hho.XOrigin > 0 and bo.ITShopInfo = 'BO' and bo.uid_OrgRoot = 'QER-V-ITShopOrg' end if exists (select top 1 1 from @alleRegeln s where s.UID_SingleGuid27  = 'QER-PWODecisionRule-P1') begin insert into @AfterAlle (Object ) select distinct hho.uid_personHead from BaseTree bo join helperHeadOrg hho on BO.UID_OrgProfitCenter28 = hho.uid_org and hho.XOrigin > 0 and bo.ITShopInfo = 'SH' and bo.uid_OrgRoot = 'QER-V-ITShopOrg' end if exists (select top 1 1 from @alleRegeln s where29 s.UID_SingleGuid  = 'QER-PWODecisionRule-P2') begin insert into @AfterAlle (Object ) select distinct hho.uid_personHead from BaseTree bo join helperHeadOrg30 hho on BO.UID_OrgProfitCenter = hho.uid_org and hho.XOrigin > 0 and bo.ITShopInfo = 'SC' and bo.uid_OrgRoot = 'QER-V-ITShopOrg' end if exists (select 31top 1 1 from @alleRegeln s where s.UID_SingleGuid  = 'QER-PWODecisionRule-H0') begin insert into @AfterAlle (Object ) select distinct hho.uid_PersonHead32 from BaseTree b join helperHeadOrg hho on b.uid_Org = hho.uid_org and hho.XOrigin > 0 where b.ITShopInfo = 'BO' and b.uid_OrgRoot = 'QER-V-ITShopOrg' 33end if exists (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  = 'QER-PWODecisionRule-H1') begin insert into @AfterAlle (Object ) select distinct34 hho.uid_PersonHead from BaseTree b join helperHeadOrg hho on b.uid_Org = hho.uid_org and hho.XOrigin > 0 where b.ITShopInfo = 'SH' and b.uid_OrgRoot =35 'QER-V-ITShopOrg' end if exists (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  = 'QER-PWODecisionRule-H2') begin insert into @AfterAlle (Object36 ) select distinct hho.uid_PersonHead from BaseTree b join helperHeadOrg hho on b.uid_org = hho.uid_org and hho.XOrigin > 0 where b.ITShopInfo = 'SC' and37 b.uid_OrgRoot = 'QER-V-ITShopOrg' end if exists (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  = 'QER-PWODecisionRule-DM') begin insert into38 @AfterAlle (Object ) select distinct hho.uid_personHead from BaseTree  d join helperHeadOrg hho on d.uid_org = hho.uid_Org and hho.XOrigin > 0 and d.uid_orgroot39 = 'QER-V-Department' end if exists (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  = 'QER-PWODecisionRule-PM') begin insert into @AfterAlle40 (Object ) select distinct hho.uid_personHead from ProfitCenter p join helperHeadOrg hho on p.uid_ProfitCenter = hho.uid_org and hho.XOrigin > 0 end if41 exists (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  = 'QER-PWODecisionRule-CM') begin insert into @AfterAlle (Object ) select distinct uid_personHead42 from helperHeadPerson where XOrigin > 0 end if exists (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  = 'QER-PWODecisionRule-PP') begin insert43 into @AfterAlle (Object ) select distinct hho.uid_personHead from BaseTree  pr join helperHeadOrg hho on pr.UID_Org = hho.uid_org and hho.XOrigin > 0 44and pr.UID_OrgRoot = 'QER-V-ProfitCenter' end if exists (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  = 'QER-PWODecisionRule-DP') begin insert45 into @AfterAlle (Object ) select distinct hho.uid_personHead from BaseTree  pr join helperHeadOrg hho on pr.UID_Org = hho.uid_org and hho.XOrigin > 0 46and pr.uid_orgroot = 'QER-V-Department' end if exists (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  in( 'QER-PWODecisionRule-PR', 'QER-PWODecisionRule-RP'47)) begin insert into @AfterAlle (Object ) select distinct pib.uid_person from BaseTree  pr join personinBaseTree pib on pr.UID_RulerContainer = pib.uid_org48 and pr.UID_OrgRoot = 'QER-V-ProfitCenter' and pib.XOrigin > 0 end if exists (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  in( 'QER-PWODecisionRule-PI'49, 'QER-PWODecisionRule-IP')) begin insert into @AfterAlle (Object ) select distinct pib.uid_person from BaseTree  pr join personinBaseTree pib on pr.UID_RulerContainerIT50 = pib.uid_org and pr.UID_OrgRoot = 'QER-V-ProfitCenter' and pib.XOrigin > 0 end if exists (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  in51( 'QER-PWODecisionRule-DR', 'QER-PWODecisionRule-RD')) begin insert into @AfterAlle (Object ) select distinct pib.uid_person from BaseTree  pr join personinBaseTree52 pib on pr.UID_RulerContainer = pib.uid_org and pr.uid_orgroot = 'QER-V-Department' and pib.XOrigin > 0 end if exists (select top 1 1 from @alleRegeln 53s where s.UID_SingleGuid  in( 'QER-PWODecisionRule-DI', 'QER-PWODecisionRule-ID')) begin insert into @AfterAlle (Object ) select distinct pib.uid_person54 from BaseTree  pr join personinBaseTree pib on pr.UID_RulerContainerIT = pib.uid_org and pr.uid_orgroot = 'QER-V-Department' and pib.XOrigin > 0 end if55 exists (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  = 'QER-PWODecisionRule-IL') begin insert into @AfterAlle (Object ) select distinct pib.uid_person56 from BaseTree  pr join personinBaseTree pib on pr.UID_RulerContainerIT = pib.uid_org and pr.UID_OrgRoot = 'QER-V-Locality' and pib.XOrigin > 0 end if 57exists (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  = 'QER-PWODecisionRule-RL') begin insert into @AfterAlle (Object ) select distinct pib.uid_person58 from BaseTree  pr join personinBaseTree pib on pr.UID_RulerContainer = pib.uid_org and pr.UID_OrgRoot = 'QER-V-Locality' and pib.XOrigin > 0 end if exists59 (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  = 'RMB-PWODecisionRule-IO') begin insert into @AfterAlle (Object ) select distinct pib.uid_person60 from BaseTree  pr join personinBaseTree pib on pr.UID_RulerContainerIT = pib.uid_org and pr.UID_OrgRoot like '____[^V]%' and pib.XOrigin > 0 end if exists61 (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  = 'RMB-PWODecisionRule-RO') begin insert into @AfterAlle (Object ) select distinct pib.uid_person62 from BaseTree  pr join personinBaseTree pib on pr.UID_RulerContainer = pib.uid_org and pr.UID_OrgRoot like '____[^V]%' and pib.XOrigin > 0 end if exists63 (select top 1 1 from @alleRegeln s where s.UID_SingleGuid  = 'QER-PWODecisionRule-OA') begin insert into @AfterAlle (Object ) select pio.uid_person from64 personinBaseTree pio join accproduct a on pio.uid_org = a.uid_orgruler and pio.XOrigin > 0  group by pio.uid_person  end      if exists (select top 1 651 from @alleRegeln s where s.UID_SingleGuid  in( 'CPL-PWODecisionRule-OC', 'CPL-PWODecisionRule-OH')) begin insert into @AfterAlle (Object ) select distinct66 pio.uid_person from personinBaseTree pio join compliancerule cr on cr.uid_orgruler = pio.uid_org and pio.XOrigin > 0 where cr.isinactive=0 and cr.isexceptionallowed=167 and cr.isworkingcopy=0 end insert into @AfterKomplett (UID_SingleGuid ) select distinct Object  from @AfterAlle a where a.Object > ' '  exec QBM_PSessionContextSet68 'GenProcID', @GenProcID delete pwoHelperDecisionMaker where not exists (select top 1 1 from @AfterKomplett t where t.UID_SingleGuid  = pwoHelperDecisionMaker.uid_personhead69 ) insert into pwoHelperDecisionMaker (uid_personHead) select t.UID_SingleGuid  from @AfterKomplett t where not exists (select top 1 1 from pwoHelperDecisionMaker70 m where m.uid_personhead = t.UID_SingleGuid  ) END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default RAISERROR ('', 18, 1) WITH NOWAIT END CATCH  ende:71 exec QBM_PSessionContextSet 'GenProcID', @GenProcID_R return end 72