OnTaskEvent Handler System variable - ExecutionValue not working in Execute task expression

  • Hi

    I am using the custom logging with the use of Execute SQL Tasks (through SQL Source property and expressions) and Event Handlers.

    I have the PreExecute, PostExecute, OnError, OnWarning and OnInformation event handlers all working in the manner I would like. I understand there is an issue already reported to Microsoft with the OnQueryCancel and OnExecStatusChanged event handlers, both of which would not be very useful in anycase.

    I am struggling to get the OnTaskFailed event handler working though.

    This is the SQL Insert statement I have written and entered into the SQLStatementSource property of the Execute SQL Task -

    " INSERT INTO log_PkgStgAltoDdUsers (

    EventLoggedDateTime,

    EventType,

    EventTaskID,

    EventTaskName,

    PackageID,

    PackageName,

    PackageCreationDateTime,

    PackageVersionBuild,

    PackageCreatedBy,

    PackageExecutedBy,

    PackageExecutedOnMachine,

    PackageExecutionID,

    PackageExecutionStartDateTime,

    TaskID,

    TaskName,

    TaskExecutionStartDateTime,

    TaskExecutionStatus

    )

    VALUES (

    '"+ SUBSTRING( (DT_WSTR, 29) GETDATE(), 1, 23) +"',

    'OnTaskFailed',

    '"+ @[System::TaskID] +"',

    '"+ @[System::TaskName] +"',

    '"+ @[System::PackageID] +"',

    '"+ @[System::PackageName] +"',

    '"+ (DT_WSTR, 19) (DT_DBTIMESTAMP) @[System::CreationDate] +"',

    '"+ (DT_WSTR, 4) @[System::VersionBuild] +"',

    '"+ @[System::CreatorName] +"',

    '"+ @[System::UserName] +"',

    '"+ @[System::MachineName] +"',

    '"+ @[System::ExecutionInstanceGUID] +"',

    '"+ (DT_WSTR, 19) (DT_DBTIMESTAMP) @[System::StartTime] +"',

    '"+ @[System::SourceID] +"',

    '"+ @[System::SourceName] +"',

    '"+ (DT_WSTR, 19) (DT_DBTIMESTAMP) @[System::ContainerStartTime] +"',

    '"+ @[System::ExecutionValue] +"'

    )

    "

    When I try and evaluate this expression I receive the following error message -

    The data type of variable "System::ExecutionValue" is not supported in an expression.

    Reading the variable "System::ExecutionValue" failed with error code 0xC00470D0.

    (Microsoft.DataTransformationServices.Controls)

    I know the ExecutionValue is a DBNull datatype but what do I need to do get this working?

    The field in my table that will be accepting the value from this system variable is defined as -

    [TaskExecutionStatus] [varchar](20) NULL,

    If I need to change the datatype of the field above, then please can let someone let me know?

    I have tried creating a package scope variable with the contents of the above the SQL insert statement and using variable (whilst setting EvaluateAsExpression as True) input on my Execute SQL Task within the OnTaskFailed event handler but no luck. I have also done the same by create a variable with the OnTaskFailed event handler but no luck again with this approach. The problem with both these approaches is that the SQL insert statement above uses system variables which when used within a variable just doesn't pick up the values during runtime from these system variables.

    I'm at a loss now to how to get this working, any help would be much appreciated.

    Thank you in advance.

  • Does it work if you cast it to another data type, the same way as you've already done for StartTime and ContainerStartTime, amongst others?

    John

  • John Mitchell-245523 (10/24/2012)


    Does it work if you cast it to another data type, the same way as you've already done for StartTime and ContainerStartTime, amongst others?

    John

    Hi John

    I have tried type casting using DT_STR, DT_WSTR and DT_BOOL but I receive the same error as above when I try to evaluate the expression.

    Running out of ideas, someone must have got this to work?

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply