dbo.QBM_PExecuteSQLMulti
Stored ProcedureSQL_STORED_PROCEDURESandbox DB
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_FGISessionErrorRethrow 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
1CREATE PROCEDURE QBM_PExecuteSQLMulti(2 @Statements QBM_YCursorBuffer READONLY,3 @HasDifferentGenprocID BIT = 0,4 @procid int = 0,5 @LockTimeout_ms int = 100,6 @MaxWaitTimeForLock_s float = 1.5,7 @PrintDebug BIT = 08)9AS10BEGIN11 DECLARE @ElementCount int12 DECLARE @ElementIndex int13 DECLARE @ElementBuffer QBM_YCursorBuffer14 DECLARE @GenProcID varchar(38)15 DECLARE @SQLCmd nvarchar(max)16 DECLARE @GenProcID_R varchar(38) = dbo.QBM_FGISessionContext('')17 DECLARE @GenProcID_old varchar(38) = @GenProcID_R18 DECLARE @Erg int = 019 DECLARE @Anzahl int = 020 DECLARE @DebugSwitch int = 021 SET XACT_ABORT OFF22 BEGIN TRY23 IF @HasDifferentGenprocID = 124 BEGIN25 IF @DebugSwitch > 026 BEGIN27 print 'differenzieren'28 END29 INSERT INTO @ElementBuffer(UID1,30 ContentFull)31 SELECT32 isnull(s.UID1,33 @GenProcID_R),34 s.ContentFull35 FROM @Statements s36 ORDER BY isnull(s.UID1,37 @GenProcID_R),38 s.ElementIndex39 SELECT @ElementCount = @@ROWCOUNT40 END41 ELSE42 BEGIN43 IF @DebugSwitch > 044 BEGIN45 print 'alles mit der Genprocid ' + @GenProcID_R46 END47 INSERT INTO @ElementBuffer(UID1,48 ContentFull)49 SELECT50 @GenProcID_R,51 s.ContentFull52 FROM @Statements s53 ORDER BY s.ElementIndex54 SELECT @ElementCount = @@ROWCOUNT55 END56 SELECT @ElementIndex = 157 WHILE @ElementIndex <= @ElementCount58 BEGIN59 SELECT60 TOP 1 @GenProcID = @GenProcID_old,61 @SQLCmd = bu.ContentFull62 FROM @ElementBuffer bu63 WHERE64 bu.ElementIndex = @ElementIndex65 IF @GenProcID <> @GenProcID_old66 BEGIN67 EXEC QBM_PSessionContextSet 'GenProcID',68 @GenProcID69 SELECT @GenProcID_old = @GenProcID70 IF @DebugSwitch > 071 BEGIN72 print 'Genprocid switched to ' + @GenProcID73 END74 END75 IF @DebugSwitch > 076 BEGIN77 print @SQLcmd78 END79 EXEC @Anzahl = QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLcmd,80 @LockTimeout_ms = @LockTimeout_ms,81 @MaxWaitTimeForLock_s = @MaxWaitTimeForLock_s,82 @ProcIDForJournal = @@PROCID,83 @HandleErrorSilent = 0,84 @ExecuteWithTransact = 085 IF @Anzahl > 0 AND @PrintDebug = 186 BEGIN87 print 'rows affected with ' + str(@Anzahl) print @SQLcmd88 END89 SELECT @Erg += @Anzahl90 SELECT @ElementIndex += 191 END92 END TRY93 BEGIN CATCH94 EXEC QBM_PSessionErrorAdd DEFAULT95 DECLARE @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow()96 RAISERROR(@Rethrow,97 18,98 1)99 WITH NOWAIT100 END CATCH101 ende:102 EXEC QBM_PSessionContextSet 'GenProcID',103 @GenProcID_R104 RETURN(@erg)105END
Open raw exported source
1 create procedure QBM_PExecuteSQLMulti (@Statements QBM_YCursorBuffer readonly , @HasDifferentGenprocID bit = 0 , @procid int = 0 2 , @LockTimeout_ms int = 100 , @MaxWaitTimeForLock_s float = 1.5 , @PrintDebug bit = 0 ) as begin declare @ElementCount int declare @ElementIndex int 3declare @ElementBuffer QBM_YCursorBuffer declare @GenProcID varchar(38) declare @SQLCmd nvarchar(max) declare @GenProcID_R varchar(38) = dbo.QBM_FGISessionContext4('') declare @GenProcID_old varchar(38) = @GenProcID_R declare @Erg int = 0 declare @Anzahl int = 0 declare @DebugSwitch int = 0 SET XACT_ABORT OFF BEGIN5 TRY if @HasDifferentGenprocID = 1 begin if @DebugSwitch > 0 begin print 'differenzieren' end insert into @ElementBuffer (UID1, ContentFull) select isnull6(s.UID1, @GenProcID_R), s.ContentFull from @Statements s order by isnull(s.UID1, @GenProcID_R), s.ElementIndex select @ElementCount = @@ROWCOUNT end else7 begin if @DebugSwitch > 0 begin print 'alles mit der Genprocid ' + @GenProcID_R end insert into @ElementBuffer (UID1, ContentFull) select @GenProcID_R8, s.ContentFull from @Statements s order by s.ElementIndex select @ElementCount = @@ROWCOUNT end select @ElementIndex = 1 while @ElementIndex <= @ElementCount9 begin select top 1 @GenProcID = @GenProcID_old , @SQLCmd = bu.ContentFull from @ElementBuffer bu where bu.ElementIndex = @ElementIndex if @GenProcID <>10 @GenProcID_old begin exec QBM_PSessionContextSet 'GenProcID', @GenProcID select @GenProcID_old = @GenProcID if @DebugSwitch > 0 begin print 'Genprocid switched to '11 + @GenProcID end end if @DebugSwitch > 0 begin print @SQLcmd end exec @Anzahl = QBM_PExecuteSQLWithRetry_LLP @SQLStatement = @SQLcmd , @LockTimeout_ms12 = @LockTimeout_ms , @MaxWaitTimeForLock_s = @MaxWaitTimeForLock_s , @ProcIDForJournal = @@PROCID , @HandleErrorSilent = 0 , @ExecuteWithTransact = 0 13if @Anzahl > 0 and @PrintDebug = 1 begin print 'rows affected with ' + str(@Anzahl) print @SQLcmd end select @Erg += @Anzahl select @ElementIndex += 1 14end END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default declare @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow() RAISERROR (@Rethrow, 18, 115) WITH NOWAIT END CATCH ende: exec QBM_PSessionContextSet 'GenProcID', @GenProcID_R return (@erg) end 16