dbo.QBM_PGICountTablesUsedByCode
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_FGICountTablesUsedByCode source text reference
- references source dbo.QBM_FGISessionErrorRethrow source text reference
- references source dbo.QBM_PSessionErrorAdd source text reference
Complete Source
1CREATE PROCEDURE QBM_PGICountTablesUsedByCode(2 @Statements QBM_YCursorbuffer READONLY,3 @CodeName varchar(30),4 @CodeType varchar(30),5 @OpenParenthesis nvarchar(max),6 @CloseParenthesis nvarchar(max)7)8AS9BEGIN10 DECLARE @SQLCmd nvarchar(max)11 DECLARE @ElementCount int12 DECLARE @ElementIndex int13 DECLARE @CountRefereced int = 014 DECLARE @DebugSwitch int = 015 SET XACT_ABORT OFF16 BEGIN TRY17 SET nocount18 ON19 SELECT @ElementCount = count(*)20 FROM @Statements21 SELECT @ElementIndex = 122 WHILE @ElementIndex <= @ElementCount23 BEGIN24 SELECT25 @SQLCmd = CONCAT('drop ',26 @CodeType,27 ' if exists dbo.',28 @CodeName)29 EXEC sp_executesql @SQLCmd30 SELECT31 @SQLCmd = CONCAT(@OpenParenthesis,32 s.ContentFull,33 @CloseParenthesis)34 FROM @Statements s35 WHERE36 s.ElementIndex = @ElementIndex37 IF @DebugSwitch > 038 BEGIN39 print @sqlcmd40 END41 EXEC sp_executesql @SQLCmd42 SELECT @CountRefereced += dbo.QBM_FGICountTablesUsedByCode(@CodeName)43 IF @DebugSwitch > 044 BEGIN45 print '@CountRefereced ' + str(@CountRefereced)46 END47 SELECT48 @SQLCmd = CONCAT('drop ',49 @CodeType,50 ' if exists dbo.',51 @CodeName)52 EXEC sp_executesql @SQLCmd53 SELECT @ElementIndex += 154 END55 END TRY56 BEGIN CATCH57 EXEC QBM_PSessionErrorAdd DEFAULT58 DECLARE @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow()59 RAISERROR(@Rethrow,60 18,61 1)62 WITH NOWAIT63 END CATCH64 endLabel:65 RETURN(@CountRefereced)66END
Open raw exported source
1 create procedure QBM_PGICountTablesUsedByCode( @Statements QBM_YCursorbuffer readonly , @CodeName varchar(30) , @CodeType varchar(30) , 2@OpenParenthesis nvarchar(max) , @CloseParenthesis nvarchar(max) ) as begin declare @SQLCmd nvarchar(max) declare @ElementCount int declare @ElementIndex3 int declare @CountRefereced int = 0 declare @DebugSwitch int = 0 SET XACT_ABORT OFF BEGIN TRY set nocount on select @ElementCount = count(*) from @Statements4 select @ElementIndex = 1 while @ElementIndex <= @ElementCount begin select @SQLCmd = concat( 'drop ', @CodeType, ' if exists dbo.', @CodeName) exec sp_executesql5 @SQLCmd select @SQLCmd = concat ( @OpenParenthesis, s.ContentFull , @CloseParenthesis ) from @Statements s where s.ElementIndex = @ElementIndex if @DebugSwitch6 > 0 begin print @sqlcmd end exec sp_executesql @SQLCmd select @CountRefereced += dbo.QBM_FGICountTablesUsedByCode(@CodeName) if @DebugSwitch > 0 begin7 print '@CountRefereced ' + str(@CountRefereced) end select @SQLCmd = concat( 'drop ', @CodeType, ' if exists dbo.', @CodeName) exec sp_executesql @SQLCmd8 select @ElementIndex += 1 end END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default declare @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow() 9RAISERROR (@Rethrow, 18, 1) WITH NOWAIT END CATCH endLabel: return(@CountRefereced) end 10