Using Constraints and Expressions

Using Constraints and Expressions

Rate This
  • Comments 6

Besides the regular Success and Failure constraints, you can create precedence constraints that are linked to an expression.

In this example, I have a Script Task that determines the course for the workflow.

Besides the pass and fail, I also want to handle a third case that will be executed whenever a special condition is met in the Script Task.

To set this up, I create a new Boolean variable (varSpecialCase), and set the value in my Script Task. Double clicking the “Handle Special Case” constraint brings up the Precedence Constraint Editor, where I can change the way the constraint is evaluated.

Here I’ve set “Evaluation operation” to “Expression”, and used my variable in the expression text. If varSpecialCase has been set to true by the Script Task, the “Handle Special Case” script task will be executed.

One thing to keep in mind:  =   !=   ==

(The equals sign is not the same as double equals in the constraint expression!)

I had originally set my expression up using a single equal sign.

As this is still a valid expression, it will validate successfully when you click the Test button.

When you run however, it always fails. After spending a while trying to figure out why my task wasn’t being executed, I finally looked it up the operators in the Integration Services Expression Reference. I’ll definitely look there first, next time!

 

Leave a Comment
  • Please add 3 and 4 and type the answer here:
  • Post
  • PingBack from http://paidsurveyshub.info/story.php?title=ssis-team-blog-using-constraints-and-expressions

  • So will "Handle Success" also run as well as "Handle Special Case" ?  If so, how do you create a basic "If x then blah, else blah" type construct?

  • You'd do it with two separate precedence constraints - one with the "if" expression, and one with the "else".

  • Hi Matt,

    I hope you don't mind if I share a link to SSIS 2012 Precedence Constraint Video Tutorial that covers most aspects of Precedence Constraint in 6 videos.

    Here's the link

    www.katieandemil.com/ssis-precedence-constraint-editor-tutorial-ssis-2012

    Take care

    Emil

  • When selecting only Expression for the Evaluation operation, the Value becomes greyed out suggesting that it is not applicable, however it must be set to Completion otherwise the task will fail.

  • One thing to keep in mind:  =   !=   ==

    (The equals sign is not the same as double equals in the constraint expression!)

    >>>

    Exactly what I was looking for -- thanks!

Page 1 of 1 (6 items)