Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


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


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

Author
Message
superstar6778324
superstar6778324
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 91
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:TongueackageID] +"',
'"+ @[System:TongueackageName] +"',
'"+ (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.
John Mitchell-245523
John Mitchell-245523
SSCrazy Eights
SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)SSCrazy Eights (9.1K reputation)

Group: General Forum Members
Points: 9061 Visits: 15522
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
superstar6778324
superstar6778324
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 91
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?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search