ssis endrowset没有拿起最后一排

时间:2017-03-13 17:05:16

标签: sql-server vb.net ssis etl

我正在使用脚本转换运行SSIS作业。这将读取文件,收集数组中的数据,并在键发生更改时从数组中输出数据。但是,这似乎并不处理最后一个记录/数组,因为似乎没有执行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

1 个答案:

答案 0 :(得分:1)

>>> limits.__class__.__name__ '3Tuple' 将为每一行执行。使用的目的是什么,删除while循环。

您可以使用其他方法检查最后一行:

  1. 在您的包中添加一个DataFlow Task,用于计算源文件中的行数public override void InputRows_ProcessInputRow(InputRowsBuffer Row)
  2. DFT RowCount中添加DFT RowCountFlat File Source组件
  3. 将RowCount存储在变量中(例如:RowCount
  4. User::FileRowCount连接到您正在使用的DatafLow任务
  5. 将变量DFT RowCount添加到脚本User::FileRowCount
  6. 脚本中的
  7. 使用以下代码:

    ReadOnlyVariables