4fbd0899510bf8831cc00e29627b227045936cc8
FAQ/Questions/Using-Stored-Procedures-In-Izenda-6.md
| ... | ... | @@ -15,14 +15,19 @@ Since version 6.0, Izenda Reports can expose existing SPs (Stored Procedures) in |
| 15 | 15 | |
| 16 | 16 | When SPs are detected in your MSSQL database, their names will appear in the list of available DataSources in the Report Designer. Currently, Izenda AdHoc supports only input parameters, while parameters of other types are ignored. Input parameters play the role of the columns that are used in the WHERE clause of the SELECT statement. |
| 17 | 17 | To be suitable for AdHoc, SPs must return a standard SELECT statement. This will be treated as the result of a standard SELECT statement being performed on a table. The column names returned from the SP will be available as fields in your DataSource. |
| 18 | -Example of a SP: |
|
| 18 | + |
|
| 19 | +Example of a SP using the Northwind database: |
|
| 19 | 20 | |
| 20 | 21 | ```sql |
| 21 | -CREATE PROCEDURE GetContact @companyName varchar (250) AS |
|
| 22 | - BEGIN |
|
| 23 | - SELECT ContactName, Phone FROM Customers |
|
| 24 | - WHERE CompanyName LIKE '%' @companyName '%' |
|
| 25 | - END |
|
| 22 | +USE northwind; |
|
| 23 | +GO |
|
| 24 | +CREATE PROCEDURE GetContact |
|
| 25 | + @companyName varchar(250) |
|
| 26 | +AS |
|
| 27 | + SELECT ContactName, Phone |
|
| 28 | + FROM Customers |
|
| 29 | + WHERE CompanyName LIKE '%' + @companyName + '%'; |
|
| 30 | +GO |
|
| 26 | 31 | ``` |
| 27 | 32 | |
| 28 | 33 | <a name="SampleOutput"></a>Here we have a SP named "GetContact" that accepts one input parameter, the name of a company. It returns two columns; the customer's name, and a phone number. There is also a condition that the CompanyName must be similar to the input variable @companyName. If we will execute this SP in MSSQL 2005 using the Customers table from Northwind, we will get the following result: |
| ... | ... | @@ -117,7 +122,7 @@ public override string[] ProcessEqualsSelectList(Izenda.AdHoc.Database.Column co |
| 117 | 122 | |
| 118 | 123 | Once you have completed the steps above and access your web application, you may notice there are DataSources that have "(SP)" at the end of name. After the SP is selected as the DataSource, you may continue to the Fields tab. Once you do, you may notice that some of fields have "(Param)" after their names. |
| 119 | 124 | |
| 120 | -These fields represent the input parameters of the SP, and can not be used as output fields. In our example above, we selected two fields: ContactName and Phone. These are the columns in the final SELECT statement of our SP (see [Creating SPs in MSSQL 2005 to use in Izenda Reports]().) The last thing that we need before executing our report is to set the value for the input parameter "companyName". This can be done at the Filters tab of the Report Designer. |
|
| 125 | +These fields represent the input parameters of the SP, and can not be used as output fields. In our example above, we selected two fields: ContactName and Phone. These are the columns in the final SELECT statement of our SP. The last thing that we need before executing our report is to set the value for the input parameter "companyName". This can be done at the Filters tab of the Report Designer. |
|
| 121 | 126 | |
| 122 | 127 | To assign values to parameters of your SP, you need to select the field from the previous step (the one with "(Param)" at the end of name), then select the "Equals" operator, and type in the value for the parameter. In our example, we used the name "Gourmet" as our filter value. Now the report can be saved and executed. If you were following along, then you should have a datatable with the data [described above](#SampleOutput). |
| 123 | 128 |