![]() The following example demonstrates how to access and use variables in a Script task to determine the path of package workflow. For an example of a Script task within a Foreach Loop container that processes the image files in a folder, see Working with Images with the Script Task. For example, a Foreach File enumerator returns only a file name at Index 0 and therefore requires only one variable mapping, whereas an enumerator that returns several columns of data in each row requires you to map a different variable to each column that you want to use in the Script task.Īfter you have mapped enumerated items to variables, then you must add the mapped variables to the ReadOnlyVariables property on the Script page of the Script Task Editor to make them available to your script. On the Variable Mappings page of the Foreach Loop Editor, assign variables to each item of data that is returned by a single enumerated item. Variables make this communication between the Foreach Loop container and the Script task possible. For example, when using a Foreach File enumerator, the script needs to know the current file name when using a Foreach ADO enumerator, the script needs to know the contents of the columns in the current row of data. When a Script task runs repeatedly within a Foreach Loop container, the script usually needs to work with the contents of the current item in the enumerator. Using the Script Task within a Foreach Loop Container You may need to use the VariableDispenser property instead of the Variables property if you want to work with a variable that is not available at design time but is created programmatically at run time. When using the VariableDispenser, you must handle both the locking semantics and the casting of data types for variable values in your own code. You can also use the VariableDispenser property (Dts.VariableDispenser) to work with variables in the Script task. You can use the Contains method of the Variables collection returned by the Variables property to check for the existence of a variable before using it in your code. The Script task transparently manages locking as the script reads and modifies the values of variables. Use the Value property to read from and write to individual variables. ![]() Within the script, you access variables of both types through the Variables property of the Dts object. Keep in mind that variable names are case-sensitive. You add existing variables to the ReadOnlyVariables and ReadWriteVariables lists in the Script Task Editor to make them available to the custom script. Because the Script task has Option Strict enabled, you must cast the Value property to the appropriate type before you can use it. The Value property of the Variable class is of type Object.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |