2012-12-31 54 views
2

我有两个数据库。源数据库: http://sdrv.ms/VkX8tj如何调试作为SSIS项目一部分的脚本?

和星库: http://sdrv.ms/12S7Zkc

我从第一transfering数据到第2,使用SSIS项目: sdrv.ms/YDUvU4

(不能发布第三个链接,对不便带来的不便)

正如您所看到的,我的脚本中存在错误。它会变成“该列有一个空值。”或者是精确的(由一个弹出窗口):

at Microsoft.SqlServer.Dts.Pipeline.PipelineBuffer.CheckStatusAndNull(Int32 columnIndex) at Microsoft.SqlServer.Dts.Pipeline.PipelineBuffer.GetDecimal(Int32 columnIndex) at ScriptMain.Input0_ProcessInputRow(Input0Buffer Row) at UserComponent.Input0_ProcessInput(Input0Buffer Buffer) at Microsoft.SqlServer.Dts.Pipeline.ScriptComponent.ProcessInput(Int32 InputID, PipelineBuffer buffer) at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.ProcessInput(Int32 inputID, PipelineBuffer buffer)

和(由调试器的输出):

Error: 0xC0047062 at Data Flow Task, Script Component [337]: Microsoft.SqlServer.Dts.Pipeline.ColumnIsNullException: The column has a null value. at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.HandleUserException(Exception e) at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.ProcessInput(Int32 inputID, PipelineBuffer buffer) at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostProcessInput(IDTSManagedComponentWrapper100 wrapper, Int32 inputID, IDTSBuffer100 pDTSBuffer, IntPtr bufferWirePacket) Error: 0xC0047022 at Data Flow Task, SSIS.Pipeline: SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "Script Component" (337) failed with error code 0x80131600 while processing input "Input 0" (347). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running. There may be error messages posted before this with more information about the failure.

我的脚本是完全一样的模板除了填写此一个功能:

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; 
} 

“该列有一个空值”意味着一些东西,但是它是输入列还是输出一列,哪一列是?如何弄清楚这一点?

顺便说一句,请不要关注这个项目的内容为基础的价值,因为它完成了(好吧,我会做,我希望)只能用于教育目的。

回答

3

看看你的模式,没有任何列似乎允许NULL。 Ergo,来自源列的值为NULL是不可能的。

您可以将失败的行重定向到不同的目标,然后查看它以确定违规的行。

Raj

+1

+1 Raj将错误行重定向到错误输出并检查值。过去,我使用Try/Catch来完成这项工作。从SQL 2012开始,调试脚本组件也是一个选项:http://blogs.msdn.com/b/mattm/archive/2012/01/13/script-component-debugging-in-ssis-2012.aspx – brian

+1

谢谢,当晚需要合理的方法:)。也感谢你@brian链接中的信息 - 它帮助很大,因为我无法弄清楚如何将行重定向到错误输出(我可以对每个其他块执行此操作,但脚本块似乎没有此选项) 。 – smsware

+0

@Raj错误发生在Row.HowWage和Row.ProductionHours上,所以我猜想每个INPUT小数......好吧,我会弄清楚我希望的。 :) – smsware

相关问题