Stored Procedure
Single Stored Procedure
Stored procedures are referenced in the Designer through the Query Editor window. You must define a Connection String, specify the Name of the stored procedure as well as define any needed parameter for that stored procedure. To reference a stored procedure, follow the instructions below:
- In the Property window’s drop down list of elements (see Figure 1), select the Report to be used.
Figure 1 – Properties drop down list
- In the "Data" section of the report's properties, click the "Query" field
- Click the more button . This will display the Query Editor window.
- In the Query Editor, from the drop down menu select "Stored Procedure"
- Specify the Connection String, the Name of the stored procedure
- Click "Add New" button to add parameters (see Figure 2) needed to run the stored procedure.
- In the fields, fill in the appropriate values. To remove a parameter, select the parameter and click the "Remove" button.
- Click "OK" .
Figure 2 - Query Editor Window for Stored Procedures
Nested Stored Procedure
Reports that contain nested Sub Reports can reference values from the results of the parent report’s returned record set. These values can be referenced from within the Sub Report’s parameter list.
Consider the case where a report contains one stored procedure that returns a list of every Supplier (stored procedure name "SupplierList" see figure 3).
Figure 3 - Query Editor Window for SupplierList Stored Procedure
Then suppose a sub report contains another stored procedure that returns a list of products for any provided SupplierID (this stored procedure name is "SupplierProductList"). In order to reference the SupplierID from the original stored procedure, two pound signs (#) should surround the name of the column as the "Value" for that parameter (see figure 4), for example "#SupplierID#".
Figure 4 - A stored procedure parameter referencing an ID from the parent's record set.
Any parameters that are needed to run the stored procedure can then be added by clicking on the "Add New" button and filling in the appropriate fields.
Click "OK".