Breakpoints


Many programmers use breakpoints to debug programs, viewing the value of variables and following the flow of the logic as they step through the source code. SSIS allows you to set breakpoints on the package or any Control Flow level task or container. You can also set breakpoints in Script task code just like most programming environments.

Using the Inventory Example package created in a previous section, right-click on the Inventory Query Simulator (For Loop) container, and choose Edit Breakpoints from the pop-up menu. The Set Breakpoints dialog box opens. A list of possible events where a breakpoint can be set is displayed, as shown in Figure 13-15.

image from book
Figure 13-15

Enable the last item, Break at the Beginning of Every Iteration of the Loop, which is available only for looping containers. Under Hit Type Count, you can choose Always, Hit Count Equals, Hit Count Greater Than or Equal To, or Hit Count Multiple. The last item will suspend execution when the hit count is equal to a multiple of the value set for Hit Count. For example, setting the Hit Count Type to Hit Count Multiple and the Hit Count to 5 will cause the execution to be suspended every fifth time through the loop.

Go ahead and set the type to Hit Count Multiple and the Hit Count to 5 as in Figure 13-16.

image from book
Figure 13-16

Click OK. The container will now have a red circle specifying that a breakpoint has been set (see Figure 13-17).

image from book
Figure 13-17

Run the package. When the Hit Count reaches 5, the execution will stop and the red dot will change to a red circle with an arrow. You can now view the values of the variables in the Locals window. If the Locals window is not visible, open it from Debug Windows Locals. Expand Variables and look for the User variables that were set up for the package (see Figure 13-18). User::Count should have a value of 5. If the value of a variable cannot be completely viewed in the window, such as a long string, you can mouse over to see the entire value in a tooltip.

image from book
Figure 13-18

Restart the package and it will run until the Hit Count reaches 10.

There are also Watch windows to make it easier to view the variables you are interested in viewing. Open the Watch window from Debug Windows Watch Watch 1. Type in the name of a variable, User::Count. The value automatically appears (see Figure 13-19). You can add additional variables to watch in this window or in new Watch windows. Alternately, right-click on a variable in the Locals window to add the variable to the Watch window.

image from book
Figure 13-19

Another very cool feature is the ability to change the value of variables on the fly. In the Watch window, expand User::Count. Right-click and choose Edit Value. Change the value to 40 and restart the package. The next time the execution is suspended, the value should be at 45. The value of some system variables may also be interesting to view and change. For example, you might modify the value of a task property as the package executes. You can use breakpoints and the watch windows to view the value to make sure it is what you expected or change the value manually to correct it.

An additional debugging window may also help troubleshoot packages, known as the Call Stack Window. This window shows a list of the tasks that have executed up to the breakpoint. This could be very useful when trying to figure out a very complex workflow.

The ability to set breakpoints on the tasks and containers will save you lots of time while troubleshooting your packages. Data Viewers are similar to breakpoints, but they are used to view data as the package executes. See Chapter 4 for more information on how you can use Data Viewers in your packages.



Professional SQL Server 2005 Integration Services
Wireless Java : Developing with Java 2, Micro Edition
ISBN: 189311550X
EAN: 2147483647
Year: 2006
Pages: 182

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