SSIS:从输出缓冲区中删除空行

发布于 2024-11-04 06:32:48 字数 160 浏览 5 评论 0原文

我的数据流任务出现错误。

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蛮可爱 2024-11-11 06:32:48

您说源转到异步脚本组件。如果这是真的,那么您已经在控制行何时进入输出缓冲区。

默认情况下,脚本组件是同步的。每个输入行都有一个输出行。也许这就是您当前的设置。

如果要将脚本组件用作异步组件,则必须执行以下操作:

  • 添加新脚本组件
  • 右键单击​​组件并选择显示高级编辑器...
  • 在输入和输出属性上,选择输出项并将 SynchronousInputID 值更改为 None
  • 在“输出”选项卡上,添加将定义输出缓冲区的列。您必须定义列,因为与同步脚本不同,输出缓冲区不会自动定义为与输入缓冲区匹配。

编辑脚本时,可以使用 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:

  • Add a new script component
  • Right-click on the component and select Show Advanced Editor...
  • On the Input and Output Properties, select the Output item and change the SynchronousInputID value to None
  • On the Output tab, add columns that will define the output buffer. You must define the columns because, unlike with a synchronous script, the output buffer is not automatically defined as a match to the input buffer.

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.

深海夜未眠 2024-11-11 06:32:48

为了解决这个问题,我添加了条件拆分组件,并对其中一个空白列添加了长度检查(即 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.

も星光 2024-11-11 06:32:48

问题似乎是 SSIS 在预执行期间执行 AddRow() 函数。这往往会与 public override void ProcessInputRow() 函数中使用 AddRow() 发生冲突。例如,PreExecute 创建一个新行来开始,然后您手动创建一个新行作为处理的一部分,您现在有 2 个新行,其中第一行充满 NULL,并且已经传递到输出缓冲区。为了解决这个问题,我重写 CreateNewOutputRows() 并将其保留为空,而不是只根据需要添加行,例如,如果正确的数据不添加行,我的一些异步脚本根本不会向输出缓冲区添加行。 t 显示在输入缓冲区上。

public class ScriptMain : UserComponent {

    public override void CreateNewOutputRows() {}

    public override void Input_ProcessInputRow(InputBuffer Row) {
       if(asNeeded) {
          OutputBuffer.AddRow();
       }
    }
}

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 override CreateNewOutputRows() 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.

public class ScriptMain : UserComponent {

    public override void CreateNewOutputRows() {}

    public override void Input_ProcessInputRow(InputBuffer Row) {
       if(asNeeded) {
          OutputBuffer.AddRow();
       }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文