dbo.QBM_PBufferT_FillTable
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_FCVStringToIndent source text reference
- references source dbo.QBM_FGIColumnExists source text reference
- references source dbo.QBM_FGIDBOwner source text reference
- references source dbo.QBM_FGISessionErrorRethrow source text reference
- references source dbo.QBM_FSQTableRowOwnedByModule source text reference
- references source dbo.QBM_PBufferT_FillColumn source text reference
- references source dbo.QBM_PJournal source text reference
- references source dbo.QBM_PSessionErrorAdd source text reference
Complete Source
1CREATE PROCEDURE QBM_PBufferT_FillTable(2 @TempTableName nvarchar(64),3 @TargetModule varchar(3),4 @TableName varchar(30),5 @RowCondition nvarchar(max),6 @ModuleName varchar(3) = '#'7)8AS9BEGIN10 DECLARE @DebugLevel char(1) = 'W'11 DECLARE @DebugSwitch int = 012 DECLARE @cmd nvarchar(max)13 DECLARE @columnname varchar(30)14 DECLARE @ErrorMessage nvarchar(4000)15 DECLARE @ErrorSeverity int16 DECLARE @ErrorState int17 DECLARE @ColumnNames QBM_YCursorBuffer18 DECLARE @ElementCount int19 DECLARE @ElementIndex int20 DECLARE @RowCondition_Table nvarchar(max)21 DECLARE @RowCondition_Intern nvarchar(max)22 SET XACT_ABORT OFF23 BEGIN TRY24 IF @ModuleName = '#'25 BEGIN26 SELECT @ModuleName = dbo.QBM_FGIDBOwner()27 END28 IF @TargetModule = '#'29 BEGIN30 SELECT @TargetModule = @ModuleName31 END32 SELECT @RowCondition_Table = NULL33 SELECT TOP 1 @RowCondition_Table = t.TransportWhereClause34 FROM DialogTable t35 WITH(readpast)36 WHERE37 t.TableName = @TableName AND t.TransportWhereClause > ' '38 SELECT @RowCondition_Intern = '(1=1' + CASE39 WHEN dbo.QBM_FGIColumnExists(@TableName,40 'XOrigin') = 1 THEN41 ' and ( XOrigin > 0)'42 ELSE ''43 END + CASE44 WHEN @RowCondition_Table > ' ' THEN45 ' and (' + @RowCondition_Table + ')'46 ELSE ''47 END + CASE48 WHEN @RowCondition > ' ' THEN49 ' and (' + @RowCondition + ')'50 ELSE ''51 END + ')'52 IF @DebugSwitch > 053 BEGIN54 print @RowCondition_Intern55 END56 IF @RowCondition_Intern = '(1=1)'57 BEGIN58 SELECT @RowCondition_Intern = ''59 END60 SELECT61 @cmd = N '62 select c.ColumnName63 from DialogColumn c join DialogTable t with (readpast) on c.UID_DialogTable = t.UID_DialogTable64 join information_schema.columns cc with (readpast) on c.columnname = cc.Column_name65 and t.TableName = cc.table_name66 where t.TableName = '''67 + @TableName + ''''68 SELECT69 @cmd = @cmd + N '70 and c.columnname not in (''XObjectKey''71 , ''Xtouched''72 , ''Xdateinserted'', ''Xdateupdated''73 , ''XUserInserted'', ''XUserUpdated''74 , ''XMarkedForDeletion''75-- , ''XOrigin''76 , ''XIsInEffect''77 )78 and c.IsNoTransfer = 079 '80 SELECT81 @cmd = @cmd + '82 and (exists (select top 1 183 from ' + @TableName + '84 where ' + dbo.QBM_FCVStringToIndent(dbo.QBM_FSQTableRowOwnedByModule85 (@TableName, @ModuleName, ''),86 3) + '87 )88 '89 IF @ModuleName = 'CCC'90 BEGIN91 SELECT92 @cmd = @cmd + '93 or exists (select top 1 1 94 from QBMBufferConfig cf95 where cf.TableName = ''' + @TableName + '''96 and cf.ColumnName = c.columnname97 )98 '99 END100 SELECT @cmd = @cmd + '101 ) '102 IF @DebugSwitch > 0103 BEGIN104 print @cmd105 EXEC QBM_PJournal @Cmd,106 @@procid,107 'D',108 @DebugLevel109 END110 BEGIN TRY111 INSERT INTO @ColumnNames(Ident1)112 EXEC sp_executesql @cmd113 END TRY114 BEGIN CATCH115 EXEC QBM_PSessionErrorAdd DEFAULT,116 @Cmd117 RAISERROR('',118 18,119 1)120 WITH NOWAIT121 END CATCH122 IF @DebugSwitch > 0123 BEGIN124 SELECT *125 FROM @ColumnNames126 END127 SELECT @ElementCount = count(*)128 FROM @ColumnNames129 SELECT @ElementIndex = 1130 WHILE @ElementIndex <= @ElementCount131 BEGIN132 SELECT TOP 1 @columnname = bu.Ident1133 FROM @ColumnNames bu134 WHERE135 bu.ElementIndex = @ElementIndex136 IF @DebugSwitch > 0137 BEGIN138 print char(9) + 'Dumping column ' + @columnname + ' rows: ' + @RowCondition_Intern139 END140 EXEC QBM_PBufferT_FillColumn @TempTableName,141 @TargetModule,142 @TableName,143 @columnname,144 @rowcondition = @RowCondition_Intern,145 @ModuleName = @ModuleName146 SELECT @ElementIndex += 1147 END148 END TRY149 BEGIN CATCH150 EXEC QBM_PSessionErrorAdd DEFAULT151 DECLARE @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow()152 RAISERROR(@Rethrow,153 18,154 1)155 WITH NOWAIT156 END CATCH157 endLabel:158 RETURN159END
Open raw exported source
1 create procedure QBM_PBufferT_FillTable ( @TempTableName nvarchar(64) , @TargetModule varchar(3) , @TableName varchar(30) , @RowCondition nvarchar2(max) , @ModuleName varchar(3) = '#' ) as begin declare @DebugLevel char(1) = 'W' declare @DebugSwitch int = 0 declare @cmd nvarchar(max) declare @columnname3 varchar(30) declare @ErrorMessage nvarchar(4000) declare @ErrorSeverity int declare @ErrorState int declare @ColumnNames QBM_YCursorBuffer declare @ElementCount4 int declare @ElementIndex int declare @RowCondition_Table nvarchar(max) declare @RowCondition_Intern nvarchar(max) SET XACT_ABORT OFF BEGIN TRY if @ModuleName5 = '#' begin select @ModuleName = dbo.QBM_FGIDBOwner() end if @TargetModule = '#' begin select @TargetModule = @ModuleName end select @RowCondition_Table6 = null select top 1 @RowCondition_Table = t.TransportWhereClause from DialogTable t with (readpast) where t.TableName = @TableName and t.TransportWhereClause7 > ' ' select @RowCondition_Intern = '(1=1' + case when dbo.QBM_FGIColumnExists(@TableName, 'XOrigin') = 1 then ' and ( XOrigin > 0)' else '' end + case8 when @RowCondition_Table > ' ' then ' and (' + @RowCondition_Table + ')' else '' end + case when @RowCondition > ' ' then ' and (' + @RowCondition + ')'9 else '' end + ')' if @DebugSwitch > 0 begin print @RowCondition_Intern end if @RowCondition_Intern = '(1=1)' begin select @RowCondition_Intern = '' end10 select @cmd = N'11 select c.ColumnName12 from DialogColumn c join DialogTable t with (readpast) on c.UID_DialogTable = t.UID_DialogTable13 join information_schema.columns cc with (readpast) on c.columnname = cc.Column_name14 and t.TableName = cc.table_name15 where t.TableName = '''16 + @TableName + '''' select @cmd = @cmd + N'17 and c.columnname not in (''XObjectKey''18 , ''Xtouched''19 , ''Xdateinserted'', ''Xdateupdated''20 , ''XUserInserted'', ''XUserUpdated''21 , ''XMarkedForDeletion''22-- , ''XOrigin''23 , ''XIsInEffect''24 )25 and c.IsNoTransfer = 026 '27 select @cmd = @cmd + '28 and (exists (select top 1 129 from ' + @TableName + '30 where ' + dbo.QBM_FCVStringToIndent( dbo.QBM_FSQTableRowOwnedByModule31 (@TableName , @ModuleName, ''), 3) + '32 )33 ' if @ModuleName = 'CCC' begin select @cmd = @cmd + '34 or exists (select top 1 1 35 from QBMBufferConfig cf36 where cf.TableName = '''37 + @TableName + '''38 and cf.ColumnName = c.columnname39 )40 ' end select @cmd = @cmd + '41 ) ' if @DebugSwitch > 0 begin print @cmd42 exec QBM_PJournal @Cmd, @@procid, 'D', @DebugLevel end begin try insert into @ColumnNames(Ident1 ) exec sp_executesql @cmd end try begin catch exec QBM_PSessionErrorAdd43 default, @Cmd RAISERROR ('', 18, 1) WITH NOWAIT end catch if @DebugSwitch > 0 begin select * from @ColumnNames end select @ElementCount = count(*) from44 @ColumnNames select @ElementIndex = 1 while @ElementIndex <= @ElementCount begin select top 1 @columnname = bu.Ident1 from @ColumnNames bu where bu.ElementIndex45 = @ElementIndex if @DebugSwitch > 0 begin print char(9) + 'Dumping column ' + @columnname + ' rows: ' + @RowCondition_Intern end exec QBM_PBufferT_FillColumn46 @TempTableName , @TargetModule , @TableName , @columnname , @rowcondition = @RowCondition_Intern , @ModuleName = @ModuleName select @ElementIndex += 147 end END TRY BEGIN CATCH exec QBM_PSessionErrorAdd default declare @Rethrow varchar(1000) = dbo.QBM_FGISessionErrorRethrow() RAISERROR (@Rethrow, 18, 481) WITH NOWAIT END CATCH endLabel: return end 49