100 likes | 292 Views
Database Functions. The art of saving time and code. Kevin Ford Services Consaultant Accela, Inc. The power of functions. Saves time in development Saves Code Saves Redundancy Reusable Ability to do things far beyond what standard SQL would allow you.
E N D
Database Functions The art of saving time and code Kevin Ford Services Consaultant Accela, Inc. Insert Presentation Title Here
The power of functions • Saves time in development • Saves Code • Saves Redundancy • Reusable • Ability to do things far beyond what standard SQL would allow you. • Usually fast and efficient execution Insert Presentation Title Here
How do they work? • Functions themselves are SQL queries. • Called in line with queries to retrieve data while keeping the code of the query simple. • Functions use parameters as criteria for the things that need to be returned • Stored in the database and never have to be written again. • Function on both SQL Server and Oracle
SQL without functions example. SELECT 'VALUE', ( SELECT BCB1.B1_CHECKLIST_COMMENT FROM BCHCKBOX BCB1 WHERE B.SERV_PROV_CODE = BCB1.SERV_PROV_CODE AND B.B1_PER_ID1 = BCB1.B1_PER_ID1 AND B.B1_PER_ID2 = BCB1.B1_PER_ID2 AND B.B1_PER_ID3 = BCB1.B1_PER_ID3 AND BCB1.B1_CHECKBOX_DESC = 'BOS District' ) FROM B1PERMIT B WHERE 1=1 AND B.B1_ALT_ID = 'CODX2009-00001' AND B.SERV_PROV_CODE = ‘Agency1'
SQL with Function SELECT 'VALUE', DBO.FN_GET_APP_SPEC_INFO(B.SERV_PROV_CODE, B.B1_PER_ID1, B.B1_PER_ID2, B.B1_PER_ID3, 'BOS District') District_Name FROM B1PERMIT B WHERE 1=1 AND B.B1_ALT_ID = 'CODX2009-00001' AND B.SERV_PROV_CODE = 'SACCO'
Demo and Explanation • Walk through the documentation that we have on hand and show how to look at the functions so that you can learn how they work to ensure that they are used properly.
Loading Functions into the Database • In the above example you can see that we have drilled down in the database to “Scalar-valued Functions” this is where the Accela Automation functions get loaded. After selecting “New Scalar-valued Function” simply copy, paste, and execute the function that you desire to load into the database.
Client Use • The list of functions that have been developed and will be supported by Accela is actually quite short 27 functions in all. • Do we or can we develop custom functions? • We have developed custom functions for end users so that portions of reports that had special needs could be completed. • Custom functions developed should be well documented and included with report deployment packages and instructions.
Documentation • Found on sharepoint (oasis) at the following address: Accela > Services > Technical Services > Standard Reports > AA Standard Database Functions for Reporting Note: the functions haven’t needed an update since their last release because they are so versatile