Download presentation
Presentation is loading. Please wait.
Published byShawn Payne Modified over 9 years ago
1
Stored Procedures (dynamic Order By + Web Assistant Wizard) Kevin Penny, MMCP kevin@hotgigs.com
2
Advantages Pre-compilation = faster execution Pre-compilation = faster execution Less Data transferred across network Less Data transferred across network EXAMPLE: EXAMPLE: exec sp_getproducts 12,234 exec sp_getproducts 12,234 vs. vs. SELECT Employees.Country, Employees.LastName, Employees.FirstName, Orders.ShippedDate, SELECT Employees.Country, Employees.LastName, Employees.FirstName, Orders.ShippedDate, Orders.OrderID, "Order Subtotals".Subtotal AS SaleAmount Orders.OrderID, "Order Subtotals".Subtotal AS SaleAmount FROM Employees INNER JOIN FROM Employees INNER JOIN (Orders INNER JOIN "Order Subtotals" ON Orders.OrderID = "Order Subtotals".OrderID) (Orders INNER JOIN "Order Subtotals" ON Orders.OrderID = "Order Subtotals".OrderID) ON Employees.EmployeeID = Orders.EmployeeID ON Employees.EmployeeID = Orders.EmployeeID Re-usable execution plans used by the database server for each proc Re-usable execution plans used by the database server for each proc More Secure (for inputted data) More Secure (for inputted data)
3
Disadvantages More skill required to write More skill required to write May find it to be less flexible than simple CFQUERY execution. May find it to be less flexible than simple CFQUERY execution. More planning needed for proper implementation (not always a bad thing!) More planning needed for proper implementation (not always a bad thing!)
4
Dynamic Order by Statement You need to define all possible columns that will be ordered by in your procedure You need to define all possible columns that will be ordered by in your procedure Your Ordered by columns must be grouped based on data type! Your Ordered by columns must be grouped based on data type! Your Order Direction must be accounted for as well (i.e. ascending or descending) Your Order Direction must be accounted for as well (i.e. ascending or descending)
5
Sample Order By Demonstration Example: Northwind Database – Employee Sales By Country Demonstration Example: Northwind Database – Employee Sales By Country
7
COLD FUSION Implementation Simple as passing the ‘parameters’ through the url or through a form Simple as passing the ‘parameters’ through the url or through a form i.e. ?bdate=1/1/1900&edate=1/1/2005& Orderby=Company&SortDirection=as c i.e. ?bdate=1/1/1900&edate=1/1/2005& Orderby=Company&SortDirection=as c
8
CFSTOREDPROC The call to the Procedure: The call to the Procedure:
9
Using the SQL 2K Web Assistant Using the Web Assistant to create some great simple reports leveraging your Database Server to Create the reports, in a great paginated way Using the Web Assistant to create some great simple reports leveraging your Database Server to Create the reports, in a great paginated way
10
Why? Let the Database create some great ‘offline’ pages with pagination with NO Cold fusion coding needed Let the Database create some great ‘offline’ pages with pagination with NO Cold fusion coding needed Take some load off the Application Server Take some load off the Application Server Give your customers / clients their data by creating web assistants reports for stored procs you’ve already created Give your customers / clients their data by creating web assistants reports for stored procs you’ve already created
11
Keys to Success Need a flexible way to change your report without having to go through the Setup Wizard Each time Need a flexible way to change your report without having to go through the Setup Wizard Each time Need a way to manually re- generate them, or schedule their execution (Job). Need a way to manually re- generate them, or schedule their execution (Job). Use a stored procedure that will execute the report (if report changes you can make the easy change w/in the proc. Use some specially crafted SQL to create usable HTML for your reports
12
Welcome to the Web Assistant Wizard
13
Adding Functionality Use SQL to create usable HTML elements Use SQL to create usable HTML elements Select ‘ Select ‘
14
Live Example Adding the SQL to the Stored Procedure that will give the reports some added usability and function Adding the SQL to the Stored Procedure that will give the reports some added usability and function Simple Checkbox with a link to a cfm page Simple Checkbox with a link to a cfm page Ability to ‘regenerate’ the Job via a link ( EXEC sp_runwebtask @procname = N'Northwind Web Page' ) Ability to ‘regenerate’ the Job via a link ( EXEC sp_runwebtask @procname = N'Northwind Web Page' )
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.