2017-03-13 41 views
1

我正在运行一个脚本转换的SSIS作业。这读入文件,收集数组中的数据,并在密钥更改时从数组中输出数据。但是,这似乎并没有处理最后一个记录/数组,因为EndofRowset似乎没有被执行。这被设置为一个异步脚本转换。代码除了采摘最后的阵列组ssis endrowset没有拿起最后一行

这里是冷凝代码的所有作品..

Public Overrides Sub MyInput_ProcessInputRow(ByVal Row As MyInputBuffer) 
    While Row.NextRow() 
     Process_recs(Row.AOS, Row.Session, Row.AOSTitle, CInt(Row.ResourceHrs), CInt(Row.TotalTargetNo)) 
    End While 
    If Row.EndOfRowset Then 
     MsgBox("LAST RECORD " & CStr(QTUT_count)) 
     do_output_data(QTUT_count, strAOS, IntTargetplusHours, StrQTUT) 
    End If 
End Sub 
Public Sub Process_recs(ByRef subAOS As String, ByRef subSession As String, ByRef subAOStitle As String, ByRef subResourceHrs As Integer, ByVal subTotalTargetNo As Integer) 
     'code here collects data in an aray and sends to output on change of key 
     do_output_data(QTUT_count, strAOS, IntTargetplusHours, StrQTUT) 

End Sub 
Public Sub do_output_data(ByVal QT_count As Integer, ByVal aos() As String, ByVal hrs() As Integer, ByVal QTUT() As String) 
    'data moved from array and output 

         .AddRow() 
         .Group = Trim(aos(k)) + StrSuffix 
         .SubGroup = Trim(aos(intindex)) 

End Sub 

Public Overrides Sub CreateNewOutputRows() 
End Sub 
Public Overrides Sub PostExecute() 
End Sub 
Public Overrides Sub PrimeOutput(ByVal Outputs As Integer, ByVal OutputIDs() As Integer, ByVal Buffers() As Microsoft.SqlServer.Dts.Pipeline.PipelineBuffer) 
    MyBase.PrimeOutput(Outputs, OutputIDs, Buffers) 
End Sub 

回答

1

public override void InputRows_ProcessInputRow(InputRowsBuffer Row)将执行的每一行。使用的目的是什么,删除while循环。

您可以使用另一种方法检查最后一行:

  1. 在你的包添加一个数据流任务用来从源文件DFT RowCount
  2. count行中DFT RowCount添加Flat File SourceRowCount组件
  3. 将RowCount存储在变量中(例如:User::FileRowCount
  4. 连接DFT RowCount的数据流任务中,您使用的是
  5. 添加变量User::FileRowCount脚本ReadOnlyVariables
  6. 在脚本中使用下面的代码:

    Dim intRowCount As Integer = 0 
    Dim intCurrentRow As Integer = 0 
    
    Public Overrides Sub PreExecute() 
        MyBase.PreExecute() 
        intRowCount = Variables.FileRowCount 
    End Sub 
    
    Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer) 
        intCurrentRow += 1 
    
    
         Process_recs(Row.AOS, Row.Session, Row.AOSTitle, CInt(Row.ResourceHrs), CInt(Row.TotalTargetNo)) 
    
        If intCurrentRow = intRowCount Then 
         MsgBox("LAST RECORD " & CStr(QTUT_count)) 
         do_output_data(QTUT_count, strAOS, IntTargetplusHours, StrQTUT) 
        End If 
    
    
    End Sub 
    
    Public Sub Process_recs(ByRef subAOS As String, ByRef subSession As String, ByRef subAOStitle As String, ByRef subResourceHrs As Integer, ByVal subTotalTargetNo As Integer) 
        'code here collects data in an aray and sends to output on change of key 
        do_output_data(QTUT_count, strAOS, IntTargetplusHours, StrQTUT) 
    
    End Sub 
    
    Public Sub do_output_data(ByVal QT_count As Integer, ByVal aos() As String, ByVal hrs() As Integer, ByVal QTUT() As String) 
        'data moved from array and output 
    
        .AddRow() 
        .Group = Trim(aos(k)) + StrSuffix 
        .SubGroup = Trim(aos(intindex)) 
    
    End Sub 
    
+0

非常感谢http://stackoverflow.com/users/7031230/hadi解决了我的问题。简单,当你知道如何:-) – MiguelH

+0

很高兴提供帮助 – Hadi