Back to OIM Explorer

dbo.QBM_PDBQueueCurrentResetNGen

Stored ProcedureSQL_STORED_PROCEDURESandbox DB

Stored Procedure.

Source: sandbox-db sys.sql_modules

Source size: 1.735 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_FGIDBQueueSlotResetType source text reference
  • references source dbo.QBM_PDBQCS_CurrentMoveSlot source text reference
  • references source dbo.QBM_PJournal source text reference

Complete Source

SQL79 lines
1CREATE PROCEDURE QBM_PDBQueueCurrentResetNGen(2  @SlotNumber int,3  @ErrorMessage nvarchar(max),4  @ProcIDCaller int,5  @maxGeneration int = 106)7AS8BEGIN9  DECLARE @Generation int10  DECLARE @JournalMessage nvarchar(max)11  DECLARE @SQLCmd nvarchar(max)12  DECLARE @DebugLevel char(1) = 'W'13  DECLARE @UID_Task varchar(38)14  DECLARE @SlotNumberSource int15  DECLARE @SlotNumberTarget int16  DECLARE @DBQueueToMove QBM_YDBQCSCurrentToMove17  DECLARE @RowsMoved int18  SELECT19    TOP 1 @Generation = cu.Generation,20    @UID_Task = cu.UID_Task21  FROM QBMDBQueueCurrent cu22    WITH(readpast)23  WHERE24    cu.SlotNumber = @SlotNumber25  SELECT26    @JournalMessage = CONCAT('#LDS#Temporary lock for task {0}, {1} retries left.|',27    @UID_Task,28    '|',29    str(@maxGeneration - @Generation),30    '|')31  IF @Generation < @maxGeneration32  BEGIN33    SELECT @SlotNumberSource = @SlotNumber34    SELECT @SlotnumberTarget = dbo.QBM_FGIDBQueueSlotResetType('Error06')35    DELETE @DBQueueToMove36    INSERT INTO @DBQueueToMove(UID_DialogDBQueue)37    SELECT cul.UID_DialogDBQueue38    FROM QBMDBQueueCurrent cul39      WITH(readpast)40    WHERE41      cul.SlotNumber = @SlotNumber42    EXEC @RowsMoved = QBM_PDBQCS_CurrentMoveSlot @DBQueueToMove,43      @SlotNumberSource,44      @SlotnumberTarget45    IF NOT EXISTS(46      SELECT TOP 1 147      FROM DialogDatabase48      WHERE49        IsMainDatabase = 1 AND UpdatePhase <> 0) AND NOT EXISTS(50    SELECT TOP 1 151    FROM sys.tables t52      WITH(readpast)53    JOIN sys.columns c54      WITH(readpast)55      ON t.object_id = c.object_id56    WHERE57      t.name = 'DialogDatabase' AND c.name = 'InitialMigrationRunning') AND @ProcIDCaller > 058    BEGIN59      EXEC QBM_PJournal @JournalMessage,60        @ProcIDCaller,61      'W',62        @DebugLevel63    END64    ELSE65    BEGIN66      EXEC QBM_PJournal @JournalMessage,67        @@procid,68      'I',69      'I'70    END71  END72  ELSE73  BEGIN74    RAISERROR(@ErrorMessage,75    18,76    1)77      WITH nowait78  END79END
Open raw exported source
SQL ยท Raw13 lines
1            create   procedure QBM_PDBQueueCurrentResetNGen(@SlotNumber int , @ErrorMessage nvarchar(max) , @ProcIDCaller int  , @maxGeneration 2int = 10 ) as begin declare @Generation int declare @JournalMessage nvarchar(max) declare @SQLCmd nvarchar(max) declare @DebugLevel char(1) = 'W' declare3 @UID_Task varchar(38) declare @SlotNumberSource int declare @SlotNumberTarget int declare @DBQueueToMove QBM_YDBQCSCurrentToMove declare @RowsMoved int4  select top 1 @Generation = cu.Generation , @UID_Task = cu.UID_Task from QBMDBQueueCurrent cu with (readpast) where cu.SlotNumber = @SlotNumber select5 @JournalMessage = concat('#LDS#Temporary lock for task {0}, {1} retries left.|' , @UID_Task, '|' , str(@maxGeneration - @Generation) , '|' ) if @Generation6 < @maxGeneration begin select @SlotNumberSource = @SlotNumber select @SlotnumberTarget = dbo.QBM_FGIDBQueueSlotResetType('Error06') delete @DBQueueToMove7  insert into @DBQueueToMove(UID_DialogDBQueue) select cul.UID_DialogDBQueue from QBMDBQueueCurrent cul with (readpast) where cul.SlotNumber = @SlotNumber8 exec @RowsMoved = QBM_PDBQCS_CurrentMoveSlot @DBQueueToMove, @SlotNumberSource, @SlotnumberTarget            if not exists (select top 1 1 from DialogDatabase9 where IsMainDatabase = 1 and UpdatePhase <> 0) and not exists (select top 1 1 from sys.tables t with (readpast) join sys.columns c with (readpast) on 10t.object_id = c.object_id where t.name = 'DialogDatabase' and c.name = 'InitialMigrationRunning' ) and @ProcIDCaller > 0 begin exec QBM_PJournal @JournalMessage11, @ProcIDCaller, 'W', @DebugLevel end else begin  exec QBM_PJournal @JournalMessage, @@procid, 'I', 'I' end end else begin   raiserror(@ErrorMessage, 1812, 1) with nowait end end 13