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 (
'"+ SUBSTRING( (DT_WSTR, 29) GETDATE(), 1, 23) +"',
'"+ @[System::TaskID] +"',
'"+ @[System::TaskName] +"',
'"+ (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.
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.