dbo.QBM_PSQLCheckExecutable
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_FGISessionErrorRethrow source text reference
- references source dbo.QBM_PSessionErrorAdd source text reference
References
Referenced By
- dbo.ATT_TIAttestationPolicy
- dbo.ATT_TUAttestationPolicy
- dbo.CPL_TIComplianceRule
- dbo.CPL_TIComplianceSubRule
- dbo.CPL_TUComplianceRule
- dbo.CPL_TUComplianceSubRule
- dbo.DPR_TIDPRNameSpaceHasDialogTab
- dbo.DPR_TUDPRNameSpaceHasDialogTab
- dbo.POL_TIQERPolicy
- dbo.POL_TUQERPolicy
- dbo.QBM_TIDialogDashBoardDef
- dbo.QBM_TIDialogObject
- dbo.QBM_TIDialogParameter
- dbo.QBM_TIDialogTable
- dbo.QBM_TIJobAutoStart
- dbo.QBM_TIQBMCEFDefinition
- dbo.QBM_TIQBMViewAddOn
- dbo.QBM_TUDialogDashBoardDef
- dbo.QBM_TUDialogObject
- dbo.QBM_TUDialogParameter
- dbo.QBM_TUDialogTable
- dbo.QBM_TUJobAutoStart
- dbo.QBM_TUQBMCEFDefinition
- dbo.QBM_TUQBMViewAddOn
- dbo.QER_TIDynamicGroup
- dbo.QER_TIPWODecisionRuleRulerDete
- dbo.QER_TIQEREntitlementSource
- dbo.QER_TIQERRiskIndex
- dbo.QER_TUDynamicGroup
- dbo.QER_TUPWODecisionRuleRulerDete
- dbo.QER_TUQEREntitlementSource
- dbo.QER_TUQERRiskIndex
Complete Source
1CREATE PROCEDURE QBM_PSQLCheckExecutable(2 @QueriesToCheck QBM_YParameterList READONLY,3 @RaiseError BIT = 04)5AS6BEGIN7 DECLARE @sqlcmd nvarchar(max)8 DECLARE @Content nvarchar(max)9 DECLARE @ElementKey varchar(138)10 DECLARE @DebugSwitch int = 011 DECLARE @PatNumVarStart nvarchar(1000) = '%[^'',a-z,0-9][%]%[%][^'']%'12 DECLARE @p1 int13 DECLARE @p2 int14 DECLARE @ErrorResult QBM_YParameterList15 DECLARE @Message nvarchar(4000)16 DECLARE @errorsDetected int = 017 DECLARE @ElementBuffer QBM_YCursorBuffer18 DECLARE @ElementCount int19 DECLARE @ElementIndex int20 DECLARE @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow()21 SET XACT_ABORT OFF22 BEGIN TRY23 SET nocount24 ON25 INSERT INTO @ElementBuffer(ObjectKey1,26 ContentFull)27 SELECT28 a.Parameter1,29 N ' ' + a.ContentFull + N ' '30 FROM @QueriesToCheck a31 SELECT @ElementCount = @@ROWCOUNT32 SELECT @ElementIndex = 133 WHILE @ElementIndex <= @ElementCount34 BEGIN35 SELECT36 TOP 1 @elementKey = bu.ObjectKey1,37 @Content = bu.ContentFull38 FROM @ElementBuffer bu39 WHERE40 bu.ElementIndex = @ElementIndex41 IF @DebugSwitch > 242 BEGIN43 print @elementKey + ' ' + isnull(@Content,44 '<null>')45 END46 WHILE @Content LIKE '%$PC(%)$%'47 BEGIN48 m1:49 SELECT @p1 = 050 SELECT @p2 = 051 SELECT52 @p1 = PATINDEX('%$PC(%',53 @Content)54 IF @DebugSwitch > 055 BEGIN56 print @p157 END58 SELECT59 @p2 = PATINDEX('%)$%',60 SUBSTRING(@Content, @p1, 65000))61 IF @DebugSwitch > 062 BEGIN63 print @p264 END65 IF @p1 > 0 AND @p2 > 066 BEGIN67 SELECT @Content =68 LEFT(@Content,69 @p1 -1) + '''0''' + SUBSTRING(@Content,70 @p1 + @p2 + 1,71 65000)72 IF @DebugSwitch > 073 BEGIN74 print @Content75 END76 END77 ELSE78 BEGIN79 GOTO ItsReplaced180 END81 END82 ItsReplaced1:83 IF @Content LIKE @PatNumVarStart84 BEGIN85 IF @DebugSwitch > 086 BEGIN87 print '### unterdrückt für Content: ' + @content88 END89 SELECT @Content = ''90 END91 IF trim(@Content) = '0' OR trim(@Content) = ''92 BEGIN93 IF @DebugSwitch > 094 BEGIN95 print '--- nur null -- ' + @elementKey + '#' + @content+ '#'96 END97 SELECT @sqlcmd = ''98 END99 ELSE100 BEGIN101 IF @DebugSwitch > 0102 BEGIN103 print '--- war mehr -- ' + @elementKey + '#' + @content+ '#'104 END105 SELECT106 @sqlcmd = '107 -- #33934108 declare @ObjectKeys QBM_YParameterList109 declare @erg int110 select top 1 @erg = 1 from111 ( '112 + @Content + '113 ) as x 114 where 1 = 0115 '116 END117 IF @DebugSwitch = 2118 BEGIN119 print @sqlcmd120 END121 BEGIN TRY122 IF @sqlcmd > ' '123 BEGIN124 EXEC sp_executesql @sqlcmd125 END126 END TRY127 BEGIN CATCH128 SELECT129 @Message = CONCAT('SyntaxError in Element ',130 @ElementKey)131 EXEC QBM_PSessionErrorAdd DEFAULT,132 @Message133 IF @RaiseError = 1134 BEGIN135 SET XACT_ABORT136 ON137 RAISERROR(@Rethrow,138 18,139 1)140 WITH NOWAIT141 END142 ELSE143 BEGIN144 INSERT INTO @ErrorResult(Parameter1,145 ContentShort,146 ContentFull)147 SELECT148 @elementKey,149 LEFT(@sqlcmd,150 400),151 @Message152 SELECT @errorsDetected += 1153 END154 END CATCH155 SELECT @ElementIndex += 1156 END157 END TRY158 BEGIN CATCH159 IF @DebugSwitch > 0160 BEGIN161 print @sqlcmd162 END163 SELECT164 @Message =(CONCAT('SyntaxError in Element ', isnull(@ElementKey, '<none>')))165 EXEC QBM_PSessionErrorAdd DEFAULT,166 @Message167 RAISERROR(@Rethrow,168 18,169 1)170 WITH NOWAIT171 END CATCH172 endLabel:173 IF @errorsDetected > 0174 BEGIN175 SELECT176 Parameter1 AS ElementKey,177 ContentShort SQLCode,178 ContentFull AS Errormessage179 FROM @ErrorResult180 END181 RETURN182END
Open raw exported source
1 create procedure QBM_PSQLCheckExecutable (@QueriesToCheck QBM_YParameterList readonly , @RaiseError bit = 0 ) as begin declare @sqlcmd2 nvarchar(max) declare @Content nvarchar(max) declare @ElementKey varchar(138) declare @DebugSwitch int = 0 declare @PatNumVarStart nvarchar(1000) = '%[^'',a-z,0-9][%]%[%][^'']%'3 declare @p1 int declare @p2 int declare @ErrorResult QBM_YParameterList declare @Message nvarchar(4000) declare @errorsDetected int = 0 declare @ElementBuffer4 QBM_YCursorBuffer declare @ElementCount int declare @ElementIndex int declare @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow() SET XACT_ABORT5 OFF BEGIN TRY set nocount on insert into @ElementBuffer (ObjectKey1, ContentFull) select a.Parameter1, N' ' + a.ContentFull + N' ' from @QueriesToCheck6 a select @ElementCount = @@ROWCOUNT select @ElementIndex = 1 while @ElementIndex <= @ElementCount begin select top 1 @elementKey = bu.ObjectKey1 , @Content7 = bu.ContentFull from @ElementBuffer bu where bu.ElementIndex = @ElementIndex if @DebugSwitch > 2 begin print @elementKey + ' ' + isnull(@Content, '<null>'8) end while @Content like '%$PC(%)$%' begin m1: select @p1 = 0 select @p2 = 0 select @p1 = PATINDEX('%$PC(%', @Content) if @DebugSwitch > 0 begin print9 @p1 end select @p2 = PATINDEX('%)$%', SUBSTRING(@Content, @p1, 65000)) if @DebugSwitch > 0 begin print @p2 end if @p1 > 0 and @p2 > 0 begin select @Content10 = LEFT(@Content, @p1 -1 ) + '''0''' + SUBSTRING(@Content, @p1 + @p2 + 1 , 65000) if @DebugSwitch > 0 begin print @Content end end else begin goto ItsReplaced111 end end ItsReplaced1: if @Content like @PatNumVarStart begin if @DebugSwitch > 0 begin print '### unterdrückt für Content: ' + @content end select12 @Content = '' end if trim(@Content) = '0' or trim(@Content) = '' begin if @DebugSwitch > 0 begin print '--- nur null -- ' + @elementKey + '#' + @content+13 '#' end select @sqlcmd = '' end else begin if @DebugSwitch > 0 begin print '--- war mehr -- ' + @elementKey + '#' + @content+ '#' end select @sqlcmd =14 '15 -- #3393416 declare @ObjectKeys QBM_YParameterList17 declare @erg int18 select top 1 @erg = 1 from19 ( ' + @Content + '20 ) as x 21 where 1 = 022 '23 end if @DebugSwitch = 2 begin print @sqlcmd end begin TRY if @sqlcmd > ' ' begin exec sp_executesql @sqlcmd end end try begin catch select @Message = 24concat('SyntaxError in Element ' , @ElementKey ) exec QBM_PSessionErrorAdd default, @Message if @RaiseError = 1 begin set XACT_ABORT ON RAISERROR (@Rethrow25, 18, 1) WITH NOWAIT end else begin insert into @ErrorResult(Parameter1, ContentShort, ContentFull) select @elementKey, LEFT(@sqlcmd, 400), @Message select26 @errorsDetected += 1 end end catch select @ElementIndex += 1 end END TRY BEGIN CATCH if @DebugSwitch > 0 begin print @sqlcmd end select @Message = (concat27('SyntaxError in Element ' , isnull(@ElementKey, '<none>') ) ) exec QBM_PSessionErrorAdd default, @Message RAISERROR (@Rethrow, 18, 1) WITH NOWAIT END 28CATCH endLabel: if @errorsDetected > 0 begin select Parameter1 as ElementKey, ContentShort SQLCode, ContentFull as Errormessage from @ErrorResult end 29return end 30