SSIS endrowset 没有拿起最后一行

ssis endrowset not picking up last row

我是 运行 一个带有脚本转换的 SSIS 作业。这会读入一个文件,将数据收集到一个数组中,并在键发生变化时从数组中输出数据。但是,这似乎没有处理最后一个 record/array 组,因为似乎没有执行 EndofRowset。这被设置为异步脚本转换。除了选择最后一个数组组

之外,代码都有效

这是压缩代码..

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

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

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

  1. 在您的包中添加一个数据流任务,用于计算源文件中的行数DFT RowCount
  2. DFT RowCount 中添加一个 Flat File Source 和一个 RowCount 组件
  3. 将 RowCount 存储在变量中(例如:User::FileRowCount
  4. DFT RowCount 连接到您正在使用的 DatafLow 任务
  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