System Variables


System variables are a special type of variable that the IS runtime creates to expose information that would otherwise be inaccessible. For example, the very first system variable the IS team created was the System::PackageName variable. It's created at package scope, so it is visible to the contents of the entire package, and, of course, it exposes the package name. Not all system variables are found at package scope, however, and some serve different purposes than just exposing properties on containers. There are basically four classes of system variables as follows:

  • System variables that contain the value of properties on objectsThese are by far the most common and include System::PackageName and are read-only.

  • System variables that support functionalityFor example, the System::CancelEvent contains the system event that will be signaled if the package is attempting to terminate. Tasks can read this event to determine if the package is canceling execution and therefore should terminate prematurely.

  • System variables that contain parameters from eventsWhen an IS component fires an event, it also passes parameters as part of the event. The package can contain an event handler to handle the event inside the package. The control flow inside the event handler needs access to those parameters. So, the IS runtime places the values of those parameters into system variables that are scoped to the event handler for the event. For example, the OnError event handler has eight system variables. Three of them are common to all event handlers. They are System::SourceName, System::SourceID, and System::SourceDescription. These system variables contain the name, ID, and description of the component that fired the event. The other system variables on the OnError event handler, with one exception, hold the values of the parameters to the event. For example, the error code is in the System::ErrorCode variable and the error description is in the System::ErrorDescription. The one remaining variable is the System::Propagate variable.

  • System variables that control package functionsThere is only one of these in SQL Server 2005. It's called the System::Propagate variable. It is only found on event handlers and its purpose is to control the propagation of an event up to parent containers. If set to TRUE, which is the default, after the event handler executes, the event is propagated up to the parent container. To propagate the event means that the IS runtime executes the event handler by the same name on the parent container with the same parameter system variable values as the current event handler. System::Propagate is exposed as a system variable this way to inform the runtime engine to propagate the event. Propagating events in this way is useful in cases in which you want to attempt handling the same event in more than just the local event handler. One case is to set the propagate variable based on success or failure of the current event handler. For example, if the event handler succeeds, it can set System::Propagate to FALSE. If it fails, the event propagates up to the parent's event handler where it can be handled in a more general way, for example logging an error or attempting a different workflow.

The System namespace is read-only and cannot be changed. By default, system variables are hidden in the designer to help simplify the variables tray. You can click on the Show System Variables button at the upper-left of the Variables window to make them visible.



Microsoft SQL Server 2005 Integration Services
Microsoft SQL Server 2005 Integration Services
ISBN: 0672327813
EAN: 2147483647
Year: 2006
Pages: 200
Authors: Kirk Haselden

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net