SSIS 读/写脚本任务中的变量
我有一个名为 Valint 的变量,我需要在脚本任务中读取/写入该变量,但它似乎不起作用:
public class scriptmain
inherits usercomponent
dim counter as integer
dim Valint as integer
.....
Public sub new()
counter = 0
end sub
public overrides sub input0_processintputrow(byval row as input0buffer)
Dim vars as IDTSvariables100 = nothing
Me.variableDispenser.lockforread("User::Valint")
Me.variableDispenser.GetVariables(vars)
counter = CType (vars("User:: Valint").Value, integer)
vars.Unlock()
counter +=1
Me.VariableDispenser.LockoneForWrite("User::Valint", vars)
vars("User::Valint").Value = counter
vars.Unlock()
End Sub
出于某种原因,我的输出始终为 0
I have a variable called Valint that i need to read/write to in a script task, but it doesn't seem to work:
public class scriptmain
inherits usercomponent
dim counter as integer
dim Valint as integer
.....
Public sub new()
counter = 0
end sub
public overrides sub input0_processintputrow(byval row as input0buffer)
Dim vars as IDTSvariables100 = nothing
Me.variableDispenser.lockforread("User::Valint")
Me.variableDispenser.GetVariables(vars)
counter = CType (vars("User:: Valint").Value, integer)
vars.Unlock()
counter +=1
Me.VariableDispenser.LockoneForWrite("User::Valint", vars)
vars("User::Valint").Value = counter
vars.Unlock()
End Sub
For some reason my output is always 0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是在数据流任务中,是吗?您不能在脚本转换中修改变量,至少在 processinputrow 子例程期间是这样。
幸运的是,似乎您正在做的修改类型可以完成 - 只是在不同的子例程中。
Donald Farmer 所著的《SSIS Scripting Beta》书距离我有一千英里,所以请原谅这段代码的不精确性。重要的是您只能从 PostExecute 事件写入用户变量。
This is in a data flow task, yes? You can't modify a variable in the script transformation, at least during the processinputrow subroutine.
Fortunately, it seems like the type of modification you are doing can be done-just in different subroutines.
My SSIS Scripting Beta book by Donald Farmer is a thousand miles from me so please forgive the imprecision of this code. The important thing is that you can only write to the user variable from the PostExecute event.