How To Run A Stored Procedure In LegiTest

These steps and video will show you how to set up a test to execute a stored procedure in SentryOne LegiTest. This can be done for multiple reasons such as setting something up before executing other parts of your test or testing the stored procedure itself.

Step 1: Look in your LegiTest toolbox. To execute a stored procedure, you can use the Execute Query (Command) if the stored procedure has no return or no values we expect from it. We could use the Execute Query (Grid) if it's returning a result set. In this example, we will show Execute Query (Scalar) using the stored procedures return code.

Step 2: An option is to drag Execute Query (Scalar) into the test initialization steps, but for this example, we want to test the stored procedure, so we’ll drag the Execute Query (Scalar) to Execution Tracks.

Step 3: Once Execute Query (Scalar) is in the Execution Tracks, click the Execute Query (Scalar) box.

Step 4: Add a connection by clicking in the connection asset and selecting the ellipsis icon to the right of no asset selected. We used the HigherEd Connection for this example. Choose to have it return an integer. Then you’ll need to give it a query asset.

Step 5: To give it a query asset, go to Test level assets for Test 1 in Test Group 1. You will right-click inside the box and go to Data Management - Query.

Step 6: Select the new query and double-click it. Paste in the query you want to use. Write the command to execute the stored procedure. In this example, we're getting a count of students by state, passing in a value, and selecting the return code back as the scalar value we're going to use.

Step 7: You can give your query a new name by left-clicking and then go back to your execute query and pick the query asset that you just created.

Step 8:  Enter a Resource Key, which is the value it’s going to store the scalar value back into. (In our example, it is StudentCount.)

 
 
Download a Free Trial