Back to OIM Explorer

dbo.QBM_FGISessionErrorIsDeadlock

Scalar FunctionSQL_SCALAR_FUNCTIONSandbox DB

Scalar Function.

Source: sandbox-db sys.sql_modules

Source size: 1.878 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_FTSessionErrorLoad source text reference

Complete Source

SQL84 lines
1CREATE FUNCTION dbo.QBM_FGISessionErrorIsDeadlock(2  @ErrorBuffer QBM_YSessionError READONLY3) RETURNS int4AS5BEGIN6  DECLARE @erg BIT = 07  DECLARE @CursorString nvarchar(64) = N 'cur' + N 'sor'8  DECLARE @BufferIntern QBM_YSessionError9  DECLARE @LastElement int10  IF NOT EXISTS(11    SELECT TOP 1 112    FROM @ErrorBuffer)13  BEGIN14    INSERT INTO @BufferIntern(ErrorMessage,15    ErrorSeverity,16    ErrorState,17    ErrorNumber,18    ProcedureName,19    ProcedureLine,20    MessageDate,21    GenProcID,22    RepeatCounter,23    IsReThrow,24    SourceCode)25    SELECT26      ErrorMessage,27      ErrorSeverity,28      ErrorState,29      ErrorNumber,30      ProcedureName,31      ProcedureLine,32      MessageDate,33      GenProcID,34      RepeatCounter,35      IsReThrow,36      SourceCode37    FROM dbo.QBM_FTSessionErrorLoad() l38    ORDER BY l.RecordNumber39  END40  ELSE41  BEGIN42    INSERT INTO @BufferIntern(ErrorMessage,43    ErrorSeverity,44    ErrorState,45    ErrorNumber,46    ProcedureName,47    ProcedureLine,48    MessageDate,49    GenProcID,50    RepeatCounter,51    IsReThrow,52    SourceCode)53    SELECT54      ErrorMessage,55      ErrorSeverity,56      ErrorState,57      ErrorNumber,58      ProcedureName,59      ProcedureLine,60      MessageDate,61      GenProcID,62      RepeatCounter,63      IsReThrow,64      SourceCode65    FROM @ErrorBuffer66  END67  SELECT @LastElement = MAX(b.ElementIndex)68  FROM @BufferIntern b69  WHERE70    b.IsReThrow = 071  IF EXISTS(72    SELECT TOP 1 173    FROM @BufferIntern b74    WHERE75      b.ElementIndex = @LastElement AND(b.ErrorNumber IN(1205, 16943, 1222, 2021, 601, 2791) OR b.ErrorMessage LIKE '%Transaction%was deadlocked%deadlock victim%' OR76  b.ErrorMessage LIKE '%Lock request%exceeded%' OR b.ErrorMessage LIKE '%The referenced entity%was modified during DDL execution%' OR b.ErrorMessage77  LIKE '%Could not continue scan with NOLOCK due to data movement%' OR b.ErrorMessage LIKE '%Could not resolve expression for Schema-bound object or constraint%' OR78  b.ErrorMessage LIKE '%No success after all retries%' OR b.ErrorMessage LIKE '%See previous errors%'))79  BEGIN80    SELECT @erg = 181  END82  endLabel:83  RETURN(@erg)84END
Open raw exported source
SQL ยท Raw14 lines
1     create   function dbo.QBM_FGISessionErrorIsDeadlock (@ErrorBuffer QBM_YSessionError readOnly  ) returns int  as begin declare @erg bit = 0 2declare @CursorString nvarchar(64) = N'cur' + N'sor' declare @BufferIntern QBM_YSessionError declare @LastElement int if not exists (select top 1 1 from3 @ErrorBuffer ) begin insert into @BufferIntern(ErrorMessage, ErrorSeverity, ErrorState, ErrorNumber , ProcedureName, ProcedureLine, MessageDate , GenProcID4, RepeatCounter, IsReThrow, SourceCode) select ErrorMessage, ErrorSeverity, ErrorState, ErrorNumber , ProcedureName, ProcedureLine, MessageDate , GenProcID5, RepeatCounter, IsReThrow, SourceCode from dbo.QBM_FTSessionErrorLoad() l  order by l.RecordNumber end else begin insert into @BufferIntern(ErrorMessage6, ErrorSeverity, ErrorState, ErrorNumber , ProcedureName, ProcedureLine, MessageDate , GenProcID, RepeatCounter, IsReThrow, SourceCode) select ErrorMessage7, ErrorSeverity, ErrorState, ErrorNumber , ProcedureName, ProcedureLine, MessageDate , GenProcID, RepeatCounter, IsReThrow, SourceCode from @ErrorBuffer8 end select @LastElement = MAX(b.ElementIndex) from @BufferIntern b where b.IsReThrow = 0 if exists (select top 1 1 from @BufferIntern b where b.ElementIndex9 = @LastElement and (b.ErrorNumber in (1205  , 16943  , 1222  , 2021  , 601  , 2791  ) or b.ErrorMessage like '%Transaction%was deadlocked%deadlock victim%'10  or b.ErrorMessage like '%Lock request%exceeded%' or b.ErrorMessage like '%The referenced entity%was modified during DDL execution%' or b.ErrorMessage11 like '%Could not continue scan with NOLOCK due to data movement%' or b.ErrorMessage like '%Could not resolve expression for Schema-bound object or constraint%'12 or b.ErrorMessage like '%No success after all retries%' or b.ErrorMessage like '%See previous errors%' ) ) begin select @erg = 1 end endLabel: return(@erg13) end 14