9926f729ecd376fd3e35c773b6eb86ebcaf28dd2
FAQ/Questions/Using-Stored-Procedures-In-Izenda-6.md
| ... | ... | @@ -222,9 +222,32 @@ string currentReportName = HttpContext.Current.Request.QueryString["rn"]; |
| 222 | 222 | |
| 223 | 223 | ##Best Practices with Izenda |
| 224 | 224 | |
| 225 | -Since Izenda primarily uses metadata to obtain information about schemas, views, and other database objects, the same goes with stored procedures. Therefore, there are some expectations to be followed for these procedures that are to be used with Izenda. |
|
| 225 | +Izenda primarily uses metadata to obtain information about the schema, views, and other database objects, including stored procedures. Therefore, there are some expectations to be followed for these procedures that are to be used with Izenda. |
|
| 226 | 226 | |
| 227 | -Izenda sends NULL values for all parameters except dates, dates use an empty string, in a stored procedure and expects to receive column headers with no data in return. This allows Izenda to use the headers in the report designer just like a table or view to create reports. Additionally, at times Izenda needs to create a temp table from the StoredProcedure for joining to other tables and views, headers are used to create the temp table. |
|
| 227 | +Izenda sends NULL values for all parameters except dates, dates use an empty string, in a stored procedure and expects to receive column headers with no data in return. This allows Izenda to use the headers in the report designer just like a table or view to create reports. Below is a sample stored procedure that returns only the report headers when NULL values for the parameters parameters are passed from Izenda. |
|
| 228 | + |
|
| 229 | +```sql |
|
| 230 | +CREATE PROCEDURE [dbo].[CustOrdersDetail] @OrderID int |
|
| 231 | + AS |
|
| 232 | + IF @OrderID IS NULL |
|
| 233 | + BEGIN |
|
| 234 | + SELECT cast('' as nvarchar) as 'ProductName', |
|
| 235 | + cast(0 as float) as 'UnitPrice', |
|
| 236 | + cast(0 as int) as 'Quantity', |
|
| 237 | + cast(0 as float) as 'Discount', |
|
| 238 | + cast(0 as float) as 'ExtendedPrice' |
|
| 239 | + RETURN |
|
| 240 | + END |
|
| 241 | + SELECT ProductName, |
|
| 242 | + UnitPrice=ROUND(Od.UnitPrice, 2), |
|
| 243 | + Quantity, |
|
| 244 | + Discount=CONVERT(int, Discount * 100), |
|
| 245 | + ExtendedPrice=ROUND(CONVERT(money, Quantity * (1 - Discount) * Od.UnitPrice), 2) |
|
| 246 | + FROM Products P, [Order Details] Od |
|
| 247 | + WHERE Od.ProductID = P.ProductID and Od.OrderID = @OrderID |
|
| 248 | +``` |
|
| 249 | + |
|
| 250 | +Additionally, Izenda will occasionally need to create a temp table from the StoredProcedure for joining to other tables and views. The headers obtained when passing NULL parameter values are used to create this temp table. |
|
| 228 | 251 | |
| 229 | 252 | * INSERT EXEC - You cannot nest INSERT INTO ... EXEC statements in stored procedures used with Izenda. This is a limitation of SQL server. |
| 230 | 253 | * Return columns - The stored procedure MUST return the same columns in all cases. It is because the metadata expected when running the stored procedure must comply with the specifications given to it. |