【发布时间】:2019-09-29 13:31:56
【问题描述】:
我有一个大文本文件,其中包含多个不同的行。
我正在使用条件拆分,它查看行类型(字段 1)然后采取行动,主要是尝试增加变量,将单行拆分为多列(派生),然后将结果写入表.
但是,当尝试增加变量时,我收到“锁定以进行读写访问的变量集合在 PostExecute 之外不可用。”
正在使用脚本组件更新变量。
我已尝试将代码移至 PostExecute,但此时它似乎永远不会增加。
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
Dim MaximumKey As Int32 = Me.Variables.SPIParentID ' Grab value of MaxKey which was passed in
' NextKey will always be zero when we start the package.
' This will set up the counter accordingly
If (NextKey = 0) Then
' Use MaximumKey +1 here because we already have data
' and we need to start with the next available key
NextKey = MaximumKey + 1
Else
' Use NextKey +1 here because we are now relying on
' our counter within this script task.
NextKey = NextKey + 1
End If
'Row.pkAAAParentID = NextKey ' Assign NextKey to our ClientKey field on our data row
Me.Variables.SPIParentID = NextKey
End Sub
我希望能够使用我已有的条件拆分循环遍历文件,然后当它达到某个记录类型时,它将采用当前的 RecordTypeID 并将其递增,然后写入下一条记录。
【问题讨论】:
标签: sql-server vb.net ssis etl script-component