Back to OIM Explorer

dbo.QER_ZBaseTreeCollectionF

Stored ProcedureSQL_STORED_PROCEDURESandbox DB

Stored Procedure.

Source: sandbox-db sys.sql_modules

Source size: 3.419 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.QBM_PDBQueueCalculateDelta source text reference
  • references source dbo.QBM_PSessionContextSet source text reference
  • references source dbo.QBM_PSessionErrorAdd source text reference

Complete Source

SQL167 lines
1CREATE PROCEDURE QER_ZBaseTreeCollectionF(2  @SlotNumber int3)4AS5BEGIN6  DECLARE @Sourcedata QBM_YDataForDelta,7  @CountDeltaQantity int,8  @CountDeltaOrigin int9  DECLARE @lauf int10  DECLARE @ElementCount int11  DECLARE @ElementIndex int12  DECLARE @ElementLast int13  DECLARE @GenProcID varchar(38)14  DECLARE @GenProcID_R varchar(38) = dbo.QBM_FGISessionContext('')15  DECLARE @QBMDeltaHelper QBM_YDBQueueDeltaHelper16  DECLARE @DBQueueCurrent QBM_YDBQueueCurrent17  BEGIN TRY18    INSERT INTO @DBQueueCurrent(UID_DialogDBQueue,19    UID_Parameter,20    UID_SubParameter,21    GenProcID)22    SELECT23      UID_DialogDBQueue,24      UID_Parameter,25      UID_SubParameter,26      GenProcID27    FROM QBMDBQueueCurrent cu28      WITH(readpast)29    WHERE30      cu.SlotNumber = @SlotNumber31    IF @@rowcount = 032    BEGIN33      GOTO EndLabel34    END35    INSERT INTO @SourceData(IsUpcommingContent,36    XOriginAfter,37    Element,38    AssignedElement,39    XOriginBefore)40    SELECT41      0,42      0,43      co.UID_Org,44      co.UID_ParentOrg,45      146    FROM BaseTreeCollectionF co47    JOIN @DBQueueCurrent x48      ON co.UID_Org = x.uid_parameter49    INSERT INTO @QBMDeltaHelper(Element,50    AssignedElement)51    SELECT52      p.UID_Parameter,53      p.UID_Parameter54    FROM @DBQueueCurrent p55    SELECT @lauf = 156    WHILE @lauf > 057    BEGIN58      INSERT INTO @QBMDeltaHelper(Element,59      AssignedElement)60      SELECT61        DISTINCT a.Element,62        b.UID_ParentOrg63      FROM @QBMDeltaHelper a64      JOIN BaseTree b65        ON a.AssignedElement = b.UID_Org66      WHERE67        b.UID_ParentOrg > ' ' AND NOT EXISTS(68      SELECT TOP 1 169      FROM @QBMDeltaHelper h70      WHERE71        h.Element = a.Element AND h.AssignedElement = b.UID_ParentOrg)72      SELECT @lauf = @@rowcount73    END74    INSERT INTO @SourceData(IsUpcommingContent,75    XOriginAfter,76    Element,77    AssignedElement,78    XOriginBefore)79    SELECT80      1,81      1,82      Element,83      AssignedElement,84      085    FROM @QBMDeltaHelper86    EXEC QBM_PDBQueueCalculateDelta @SourceData,87      @DeltaQuantity = 0,88      @DeltaDelete = 1,89      @DeltaInsert = 1,90      @DeltaOrigin = 0,91      @CountDeltaQantity = @CountDeltaQantity OUTPUT,92      @CountDeltaOrigin = @CountDeltaOrigin OUTPUT,93      @UseIsInEffect = 0,94      @SlotNumber = @SlotNumber,95      @DBQueueCurrentExtern = @DBQueueCurrent96    IF @CountDeltaQantity > 097    BEGIN98      DECLARE @GenProcIDs_CountDeltaQuantity QBM_YCursorBuffer99      INSERT INTO @GenProcIDs_CountDeltaQuantity(UID1)100      SELECT de.GenProcID101      FROM #QBMDeltaDelete de102      UNION103      SELECT de.GenProcID104      FROM #QBMDeltaInsert de105      SELECT @ElementCount = @@ROWCOUNT106      SELECT @ElementIndex = @@IDENTITY - @ElementCount +1107      SELECT @ElementLast = @@IDENTITY108      WHILE @ElementIndex <= @ElementLast109      BEGIN110        SELECT TOP 1 @GenProcID = bu.UID1111        FROM @GenProcIDs_CountDeltaQuantity bu112        WHERE113          bu.ElementIndex = @ElementIndex114        IF EXISTS(115          SELECT TOP 1 1116          FROM #QBMDeltaDelete x117          WHERE118            x.GenProcID = @GenProcID)119        BEGIN120          EXEC QBM_PSessionContextSet 'GenProcID',121            @GenProcID122          DELETE BaseTreeCollectionF123          FROM BaseTreeCollectionF co124          WHERE125            EXISTS(126          SELECT TOP 1 1127          FROM #QBMDeltaDelete d128          WHERE129            d.AssignedElement = co.UID_ParentOrg AND d.Element = co.UID_Org AND d.GenProcID = @GenProcID)130        END131        IF EXISTS(132          SELECT TOP 1 1133          FROM #QBMDeltaInsert x134          WHERE135            x.GenProcID = @GenProcID)136        BEGIN137          EXEC QBM_PSessionContextSet 'GenProcID',138            @GenProcID139          INSERT INTO BaseTreeCollectionF(UID_Org,140          UID_ParentOrg)141          SELECT142            x.uid_org,143            x.uid_parentOrg144          FROM(145          SELECT146            Element AS uid_Org,147            AssignedElement AS uid_ParentOrg148          FROM #QBMDeltaInsert149          WHERE150            GenProcID = @GenProcID) AS x151        END152        SELECT @ElementIndex += 1153      END154    END155  END TRY156  BEGIN CATCH157    EXEC QBM_PSessionErrorAdd DEFAULT158    RAISERROR('',159    18,160    1)161      WITH NOWAIT162  END CATCH163  endLabel:164  EXEC QBM_PSessionContextSet 'GenProcID',165    @GenProcID_R166  RETURN167END
Open raw exported source
SQL ยท Raw23 lines
1     create   procedure QER_ZBaseTreeCollectionF (@SlotNumber int) AS begin declare @Sourcedata QBM_YDataForDelta , @CountDeltaQantity int , @CountDeltaOrigin2 int declare @lauf int declare @ElementCount int declare @ElementIndex int declare @ElementLast int declare @GenProcID varchar(38) declare @GenProcID_R3 varchar(38) = dbo.QBM_FGISessionContext('') declare @QBMDeltaHelper QBM_YDBQueueDeltaHelper declare @DBQueueCurrent QBM_YDBQueueCurrent BEGIN TRY insert4 into @DBQueueCurrent(UID_DialogDBQueue, UID_Parameter, UID_SubParameter, GenProcID) select UID_DialogDBQueue, UID_Parameter, UID_SubParameter, GenProcID5 from QBMDBQueueCurrent cu with (readpast) where cu.SlotNumber = @SlotNumber if @@rowcount = 0 begin goto EndLabel end insert into @SourceData( IsUpcommingContent6, XOriginAfter , Element, AssignedElement, XOriginBefore ) select 0, 0 , co.UID_Org, co.UID_ParentOrg, 1 from BaseTreeCollectionF co join @DBQueueCurrent7 x on co.UID_Org = x.uid_parameter  insert into @QBMDeltaHelper (Element, AssignedElement) select p.UID_Parameter, p.UID_Parameter from @DBQueueCurrent8 p  select @lauf = 1 while @lauf > 0 begin insert into @QBMDeltaHelper (Element, AssignedElement) select distinct a.Element, b.UID_ParentOrg from @QBMDeltaHelper9 a join BaseTree b on a.AssignedElement = b.UID_Org where b.UID_ParentOrg > ' ' and not exists (select top 1 1 from @QBMDeltaHelper h where h.Element =10 a.Element and h.AssignedElement = b.UID_ParentOrg ) select @lauf = @@rowcount end insert into @SourceData( IsUpcommingContent, XOriginAfter , Element,11 AssignedElement, XOriginBefore ) select 1, 1 , Element, AssignedElement, 0 from @QBMDeltaHelper exec QBM_PDBQueueCalculateDelta @SourceData, @DeltaQuantity12 = 0, @DeltaDelete = 1, @DeltaInsert = 1, @DeltaOrigin = 0, @CountDeltaQantity = @CountDeltaQantity output , @CountDeltaOrigin = @CountDeltaOrigin output13 , @UseIsInEffect = 0 , @SlotNumber = @SlotNumber , @DBQueueCurrentExtern = @DBQueueCurrent if @CountDeltaQantity > 0 begin declare @GenProcIDs_CountDeltaQuantity14 QBM_YCursorBuffer insert into @GenProcIDs_CountDeltaQuantity (UID1) select de.GenProcID from #QBMDeltaDelete de union select de.GenProcID from #QBMDeltaInsert15 de select @ElementCount = @@ROWCOUNT select @ElementIndex = @@IDENTITY - @ElementCount +1 select @ElementLast = @@IDENTITY while @ElementIndex <= @ElementLast16 begin select top 1 @GenProcID = bu.UID1 from @GenProcIDs_CountDeltaQuantity bu where bu.ElementIndex = @ElementIndex if exists (select top 1 1 from #QBMDeltaDelete17 x where x.GenProcID = @GenProcID ) begin exec QBM_PSessionContextSet 'GenProcID', @GenProcID delete BaseTreeCollectionF from BaseTreeCollectionF co where18 exists (select top 1 1 from #QBMDeltaDelete d where d.AssignedElement = co.UID_ParentOrg and d.Element = co.UID_Org and d.GenProcID = @GenProcID ) end19  if exists (select top 1 1 from #QBMDeltaInsert x where x.GenProcID = @GenProcID ) begin exec QBM_PSessionContextSet 'GenProcID', @GenProcID insert into20 BaseTreeCollectionF ( UID_Org, UID_ParentOrg) select x.uid_org, x.uid_parentOrg from ( select Element as uid_Org, AssignedElement as uid_ParentOrg from21 #QBMDeltaInsert where GenProcID = @GenProcID ) as x end  select @ElementIndex += 1 end  end  END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default RAISERROR22 ('', 18, 1) WITH NOWAIT END CATCH  endLabel: exec QBM_PSessionContextSet 'GenProcID', @GenProcID_R return end 23