2016-11-28 61 views
1

执行包时,我正经历一个非常奇怪的情况。由于业务需求,包中所有DFT中的派生列已由脚本任务替换。SSIS中的临时脚本任务错误

发展执行包导致该错误的语句,有时偶尔错误为“值过大而被添加到缓冲区”,有时脚本任务失败说明

System.ArgumentOutOfRangeException: Year, Month, and Day parameters describe an un-representable DateTime

OR

The milliseconds value is out of bounds (not between 0 & 999).

处决期间接收一些其它错误消息如下所述: -

Description: Unspecified error End Error Error: 2016-11-24 10:51:03.37 Code: 0xC0047062 Source: Dft_x [279]
Description: System.ArgumentOutOfRangeException: Year, Month, and Day parameters describe an un-representable DateTime. 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) End Error Error:

&

[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on Flat File Source 1 returned error code 0xC02020C4. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.

[OleDst_Pricing [165]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005 Description: "Invalid date format". [OleDst_xyz [165]] Error: There was an error with OleDst_xyz.Inputs[OLE DB Destination Input].Columns[DateColumn] on OleDst_xyz.Inputs[OLE DB Destination Input]. The column status returned was: "Conversion failed because the data value overflowed the specified type.". [OleDst_x [165]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "OleDst_xyz.Inputs[OLE DB Destination Input]" failed because error code 0xC020907A occurred, and the error row disposition on "OleDst_xyz.Inputs[OLE DB Destination Input]" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.

[FltSrc_x 1 [313]] Error: The attempt to add a row to the Data Flow task buffer failed with error code 0xC0047020.

[SSIS.Pipeline] Error: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED. The PrimeOutput method on FltSrc_BR_x 1 returned error code 0xC02020C4. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing. There may be error messages posted before this with more information about the failure.

但是扭捏DefaultMaxBufferRows & DefaultMaxBufferSize财产,我成功地执行包单独或通过SQL Server的约40倍的开发和测试环境,以确保它不会再次失败后, 。但生产执行再次失败,具有类似的日期特定错误。

我张贴包含在脚本的任务是在每个DFT的类似下面的代码: -

Public Class ScriptMain 
    Inherits UserComponent 
    Dim xyzArray() As String 
    Dim rowValue As String 
    Dim strDate As String 
    Dim columnxyz As String '= Me.Variables.MaterialMaster.ToString() 
    'Dim v1 As IDTSVariables100 


Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer) 

    rowValue = Row.XYZtoABC.ToString() + "~".ToString() 
    xyzArray = rowValue.Split(New Char() {"~"c}) 
    strDate = Row.DateColumn.ToString() 
    columnxyz = Row.columnxyz.ToString() 
    CreateNewOutputRows() 

End Sub 

Public Sub CreateNewOutputRows() 

    ResultBuffer.AddRow() 
    ResultBuffer.xyz1 = xyzArray(1) 
    ResultBuffer.xyz2 = xyzArray(2) 
    ResultBuffer.xyz3 = xyzArray(3) 
    ResultBuffer.xyz4 = xyzArray(4) 
    ResultBuffer.xyz5 = xyzArray(5) 


    ResultBuffer.Datecolumn = CDate(strDate) 
    ResultBuffer.columnxyz = columnxyz 

End Sub 

End Class 

回答

0

的问题是数据有关。您偶尔会导入无法表示为日期的数据,并尝试将其输出为日期。由于您没有任何代码来解决此问题,因此您将收到错误消息。

你可以把这个线在TRY ... CATCH块,并决定如何在字符串不能转换为日期的情况下,这样做:

ResultBuffer.Datecolumn = CDate(strDate) 
+0

对于日期列,在此任务之前使用派生列通过GETDATE()提供输入。 –

+0

然后也许它是一个不同的列,但答案的一般点仍然是正确的。它与数据相关,偶尔会试图将值填充到无法保存的数据类型中。一种解决方案是在发生错误时使用TRY..CATCH来处理错误。 –

0

如果strDate有特定的格式(即:"dd-MM-yyyy HH:mm:ss")。你必须使用Date.ParseExact()功能如下所示:

ResultBuffer.Datecolumn = Date.ParseExact(strDate,"dd-MM-yyyy HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None) 

此外,如果你有很多特定的格式,你可以声明一个字符串数组并将它传递给这个函数如下所示:

dim strFormats() as string = {"dd-MM-yyyy","yyyy-MM-dd"} 
ResultBuffer.Datecolumn = Date.ParseExact(strDate,strFormats,System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None) 

CDate功能有关区域设置,所以最好的做法是用Date.ParseExact

还有一点工作是使用DB_TIMESTAMP作为列类型,而不是DT_DATE

+0

strDate在脚本任务之前通过派生列从GETDATE()获取输入。它仍然需要使用Date.ParseExact()? –

+0

@MominGoni GETDATE()取决于SQL Server排序规则,CDATE()取决于机器区域设置 – Yahfoufi

+0

@MominGoni尝试使用列类型'DB_TIMESTAMP'而不是'DT_DATE' – Yahfoufi