dbo.QBM_PBufferT_FillColumn_CCC
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_FCVIntToString source text reference
- references source dbo.QBM_FCVStringToIndent source text reference
- references source dbo.QBM_FGIColumnDataLen source text reference
- references source dbo.QBM_FGIColumnDataType source text reference
- references source dbo.QBM_FGISessionErrorRethrow source text reference
- references source dbo.QBM_FSQCVColumnToBuffer source text reference
- references source dbo.QBM_PBufferT_FillColumn source text reference
- references source dbo.QBM_PSessionErrorAdd source text reference
Complete Source
1CREATE PROCEDURE QBM_PBufferT_FillColumn_CCC(2 @TableName varchar(30),3 @ColumnName varchar(30),4 @RowCondition nvarchar(max) = NULL,5 @TempTableName varchar(30) = N ''6)7AS8BEGIN9 DECLARE @datatype nvarchar(64)10 DECLARE @DataMaxLen int11 DECLARE @cmd nvarchar(max)12 DECLARE @DebugSwitch int = 013 DECLARE @PKName1 varchar(30),14 @PKName2 varchar(30)15 SET XACT_ABORT OFF16 BEGIN TRY17 SELECT18 @DataMaxLen = dbo.QBM_FGIColumnDataLen(@TableName,19 @ColumnName)20 SELECT21 @datatype = dbo.QBM_FGIColumnDataType(@TableName,22 @ColumnName)23 SELECT24 TOP 1 @PKName1 = isnull(t.PKName1,25 ''),26 @PKName2 = isnull(t.PKName2,27 '')28 FROM DialogTable t29 WHERE30 t.TableName = @TableName31 IF @DebugSwitch > 032 BEGIN33 print char(9) + char(9) + '-- ' + @TableName + '.' + @ColumnName + ' ' + @datatype + '(' + dbo.QBM_FCVIntToString(@DataMaxLen) + ')'34 END35 SELECT36 @cmd = CONCAT('inser',37 't into ',38 @TempTableName,39 '(TargetFile, moduleName, TableName, ColumnName, ObjectKeyOfRow, ContentShort, HasContentFull, ContentFull)40 select ''M''as TargetFile, ''CCC'', ''@TableName@'', ''@ColumnName@'', @TableName@.XObjectKey, '41 ,42 dbo.QBM_FCVStringToIndent(dbo.QBM_FSQCVColumnToBuffer(@TableName, @ColumnName, @TableName), 2),43 '44 from @TableName@ with (readpast)',45 ' 46 where @TableName@.@PKName1@ like ''[a-z][0-9,a-z][0-9,a-z]-%''47 ',48 CASE49 WHEN @PKName2 > ' ' THEN50 'and @TableName@.@PKName2@ like ''[a-z][0-9,a-z][0-9,a-z]-%'' '51 ELSE ''52 END,53 '54 and (@TableName@.@PKName1@ like ''CCC-%'' ',55 CASE56 WHEN @PKName2 > ' ' THEN57 '58 or @TableName@.@PKName2@ like ''CCC-%'' '59 ELSE ''60 END,61 '62 or exists ( select top 1 163 from QBMBufferConfig co with (readpast)64 where co.ObjectKeyOfRow = @TableName@.XObjectKey65 and co.Tablename = ''@TableName@''66 and co.ColumnName = ''@ColumnName@''67 )68 '69 ,70 '71 )',72 CASE73 WHEN @RowCondition > ' ' THEN74 '75 and ( ' + @RowCondition + ')'76 ELSE ''77 END,78 '79 order by @TableName@.XObjectKey')80 SELECT81 @cmd = replace(replace(replace(REPLACE(@cmd, '@ColumnName@', @ColumnName), '@TableName@', @TableName),82 '@PKName1@', @PKName1),83 '@PKName2@',84 @PKName2)85 IF @DebugSwitch > 086 BEGIN87 print @cmd88 END89 EXEC sp_executeSQL @cmd90 END TRY91 BEGIN CATCH92 EXEC QBM_PSessionErrorAdd DEFAULT93 DECLARE @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow()94 RAISERROR(@Rethrow,95 18,96 1)97 WITH NOWAIT98 END CATCH99END
Open raw exported source
1 create procedure QBM_PBufferT_FillColumn_CCC ( @TableName varchar(30) , @ColumnName varchar(30) , @RowCondition nvarchar(max) = null , 2@TempTableName varchar(30) = N'' ) as begin declare @datatype nvarchar(64) declare @DataMaxLen int declare @cmd nvarchar(max) declare @DebugSwitch int3 = 0 declare @PKName1 varchar(30) , @PKName2 varchar(30) SET XACT_ABORT OFF BEGIN TRY select @DataMaxLen = dbo.QBM_FGIColumnDataLen(@TableName , @ColumnName4) select @datatype = dbo.QBM_FGIColumnDataType(@TableName , @ColumnName) select top 1 @PKName1 = isnull(t.PKName1, '') , @PKName2 = isnull(t.PKName2, ''5) from DialogTable t where t.TableName = @TableName if @DebugSwitch > 0 begin print char(9) + char(9) + '-- ' + @TableName + '.' + @ColumnName + ' ' + 6@datatype + '(' + dbo.QBM_FCVIntToString(@DataMaxLen) + ')' end select @cmd = concat('inser','t into ' , @TempTableName , '(TargetFile, moduleName, TableName, ColumnName, ObjectKeyOfRow, ContentShort, HasContentFull, ContentFull)7 select ''M''as TargetFile, ''CCC'', ''@TableName@'', ''@ColumnName@'', @TableName@.XObjectKey, '8 , dbo.QBM_FCVStringToIndent (dbo.QBM_FSQCVColumnToBuffer (@TableName , @ColumnName, @TableName ), 2) , '9 from @TableName@ with (readpast)' , ' 10 where @TableName@.@PKName1@ like ''[a-z][0-9,a-z][0-9,a-z]-%''11 '12 , case when @PKName2 > ' ' then 'and @TableName@.@PKName2@ like ''[a-z][0-9,a-z][0-9,a-z]-%'' ' else '' end , '13 and (@TableName@.@PKName1@ like ''CCC-%'' '14 , case when @PKName2 > ' ' then '15 or @TableName@.@PKName2@ like ''CCC-%'' ' else '' end , '16 or exists ( select top 1 117 from QBMBufferConfig co with (readpast)18 where co.ObjectKeyOfRow = @TableName@.XObjectKey19 and co.Tablename = ''@TableName@''20 and co.ColumnName = ''@ColumnName@''21 )22 '23 , '24 )' , case when @RowCondition > ' ' then '25 and ( ' + @RowCondition + ')' else '' end , '26 order by @TableName@.XObjectKey' ) select @cmd27 = replace(replace(replace(REPLACE(@cmd , '@ColumnName@', @ColumnName) , '@TableName@', @TableName ) , '@PKName1@', @PKName1) , '@PKName2@', @PKName2) 28if @DebugSwitch > 0 begin print @cmd end exec sp_executeSQL @cmd END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default declare @Rethrow varchar(1000) =29 dbo.QBM_FGISessionErrorRethrow() RAISERROR (@Rethrow, 18, 1) WITH NOWAIT END CATCH end 30