我有兩個數據庫。源數據庫: http://sdrv.ms/VkX8tj如何調試作爲SSIS項目一部分的腳本?
我從第一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;
}
「該列有一個空值」意味着一些東西,但是它是輸入列還是輸出一列,哪一列是?如何弄清楚這一點?
順便說一句,請不要關注這個項目的內容爲基礎的價值,因爲它完成了(好吧,我會做,我希望)只能用於教育目的。
+1 Raj將錯誤行重定向到錯誤輸出並檢查值。過去,我使用Try/Catch來完成這項工作。從SQL 2012開始,調試腳本組件也是一個選項:http://blogs.msdn.com/b/mattm/archive/2012/01/13/script-component-debugging-in-ssis-2012.aspx – brian
謝謝,當晚需要合理的方法:)。也感謝你@brian鏈接中的信息 - 它幫助很大,因爲我無法弄清楚如何將行重定向到錯誤輸出(我可以對每個其他塊執行此操作,但腳本塊似乎沒有此選項) 。 – smsware
@Raj錯誤發生在Row.HowWage和Row.ProductionHours上,所以我猜想每個INPUT小數......好吧,我會弄清楚我希望的。 :) – smsware