2017-03-13 71 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