SSIS:从输出缓冲区中删除空行
我的数据流任务出现错误。
我有一个 ado.net 源代码,用于异步脚本组件。
问题出现在从脚本组件插入到目标的最后,它
试图将空行自动放入我的表中的输出缓冲区中。
有没有办法防止这种情况发生/我如何操作输出缓冲区,以便我可以从中删除特定行?
I have an error on a data flow task.
i have an ado.net source going to an async script component.
the problem comes at the very end of the insert from the script component to the destination where it
tries to put the empty row it automatically puts in the output buffer in my table.
Is there a way to prevent this from happening/ how can i manipulate the output buffer so i can remove specific rows from it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您说源转到异步脚本组件。如果这是真的,那么您已经在控制行何时进入输出缓冲区。
默认情况下,脚本组件是同步的。每个输入行都有一个输出行。也许这就是您当前的设置。
如果要将脚本组件用作异步组件,则必须执行以下操作:
编辑脚本时,可以使用 OutputBuffer.AddRow 方法在输出缓冲区中创建新行。每次调用 AddRow 时,现有缓冲区内容都会从脚本组件发送出去,并清除以用于下一行。使用跳过行的规则,您将在添加或跳过行之前验证输入缓冲区。
You say that the source goes to an async script component. If this is true, then you are already controlling when rows go to the output buffer.
By default, a script component is synchronous. There is one output row for each input row. Maybe this is what you currently have setup.
If you want to use a script component as an asynchronous component, you have to do the following:
When you edit the script, you can use the OutputBuffer.AddRow method to create new rows in the output buffer. Each time you call AddRow, the existing buffer content is sent out of the script component and cleared for the next row. Using your rules for skipping rows, you will validate the input buffer before adding or skipping the row.
为了解决这个问题,我添加了条件拆分组件,并对其中一个空白列添加了长度检查(即 len([testfield])>0)。然后,我将带有该检查的这些字段发送到数据库,并且对其他分支不执行任何操作。
To solve this issue, I added the conditional split component and added a length check on one of the blank columns (i.e len([testfield])>0). I then sent those fields with that check to the database and did nothing for the other branch.
问题似乎是 SSIS 在预执行期间执行 AddRow() 函数。这往往会与
public override void ProcessInputRow()
函数中使用 AddRow() 发生冲突。例如,PreExecute 创建一个新行来开始,然后您手动创建一个新行作为处理的一部分,您现在有 2 个新行,其中第一行充满 NULL,并且已经传递到输出缓冲区。为了解决这个问题,我重写CreateNewOutputRows()
并将其保留为空,而不是只根据需要添加行,例如,如果正确的数据不添加行,我的一些异步脚本根本不会向输出缓冲区添加行。 t 显示在输入缓冲区上。The Problem seems to be SSIS executing the AddRow() Function during PreExecute. This then tends to clash with any use of AddRow() in your
public override void ProcessInputRow()
Function. e.g. PreExecute makes a new row to kick things off and then you manually create a new row as a part of your processing, you now have 2 new rows, the first of which is full of NULLS and already passed to the outputbuffer. To fix this i overrideCreateNewOutputRows()
and leave it empty, than only add rows as i need, e.g. some of my asynchronous scripts never add a row at all to the output buffer if the correct data doesn't show up on the input buffer.