如何调试脚本是SSIS项目的一部分

本文关键字:SSIS 项目 一部分 脚本 何调试 调试 | 更新日期: 2023-09-27 17:49:58

我有两个数据库。源数据库:http://sdrv.ms/VkX8tj

and star database:http://sdrv.ms/12S7Zkc

我正在使用SSIS项目将数据从1号传输到2号:sdrv.ms/YDUvU4

(不能发布第三个链接,抱歉给您带来不便)

你可以看到,有一个错误在我的脚本。它是"该列有一个空值"或者更确切地说(通过弹出窗口):

在Microsoft.SqlServer.Dts.Pipeline.PipelineBuffer

。CheckStatusAndNull (Int32 columnIndex)在Microsoft.SqlServer.Dts.Pipeline.PipelineBuffer。GetDecimal (Int32 columnIndex)在ScriptMain。Input0_ProcessInputRow (Input0Buffer行)在UserComponent。Input0_ProcessInput (Input0Buffer缓冲)在Microsoft.SqlServer.Dts.Pipeline.ScriptComponent。ProcessInput(Int32 InputID, PipelineBuffer buffer)在Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost。ProcessInput(Int32 inputID, PipelineBuffer buffer)

和(由调试器的输出):

错误:0xC0047062 at Data Flow Task, Script Component [337]: Microsoft.SqlServer.Dts.Pipeline.ColumnIsNullException:列有一个空值。在Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost。HandleUserException(异常e)在Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost。ProcessInput(Int32 inputID, PipelineBuffer buffer)在Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost。HostProcessInput(IDTSManagedComponentWrapper100 wrapper, Int32 inputID, IDTSBuffer100 pDTSBuffer, IntPtr bufferWirePacket)错误:0xC0047022在数据流任务,SSIS。管道:SSIS错误码dtse_processinputfailed。在处理输入"input 0"(347)时,组件"Script component"(337)上的ProcessInput方法失败,错误代码为0x80131600。标识的组件从ProcessInput方法返回一个错误。该错误是特定于组件的,但该错误是致命的,并将导致Data Flow任务停止运行。在此之前可能会发布错误消息,其中包含有关失败的更多信息。

我的脚本是完全按照模板,除了填写这一个函数:

public override void Input0_ProcessInputRow(Input0Buffer Row)
{
    decimal WorkerWage = Row.Amount * Row.HourWage * Row.ProductionHours;
    Row.WorkerWage = WorkerWage;
    decimal TotalProductionCost = Row.Amount * Row.ProductionHours * (Row.ProductionCost + Row.HourCost) + WorkerWage;
    Row.TotalProductionCost = TotalProductionCost;
    decimal StandardPrice = TotalProductionCost * (1 + Row.Profit/100);
    Row.StandardPrice = StandardPrice;
    decimal TotalDiscount = StandardPrice * (Row.Discount / 100);
    Row.TotalDiscount = TotalDiscount;
    decimal TotalPrice = StandardPrice - TotalDiscount;
    Row.TotalPrice = TotalPrice;
    decimal TotalShippingCost = Row.ShippingCost + TotalPrice * (Row.ShippingTax / 100);
    Row.TotalShippingCost = TotalShippingCost;
    decimal RealProfit = TotalPrice - TotalProductionCost;
    Row.RealProfit = RealProfit;
    decimal TraderMargin = RealProfit * (Row.ProfitMargin / 100);
    Row.TraderMargin = TraderMargin;
}

"列有一个空值"意味着什么,但它是输入列还是输出列,到底是哪一个?怎么算出来呢?

顺便说一下,请不要关注这个项目的内容价值,因为它只用于教育目的。

如何调试脚本是SSIS项目的一部分

查看您的模式,似乎没有列允许NULL。因此,源列的值为NULL是不可能的。

您可以将失败的行重定向到不同的目的地,并查看它以识别有问题的行。

Raj