4-1. Creating a Stored Function
One of your programs is using a few lines of code repeatedly for performing a calculation. Rather than using the same lines of code numerous times throughout your application, it makes more sense to encapsulate the functionality into a common routine that can be called and reused time and time again.
Create a stored function to encapsulate your code, and save it into the database. Once stored in the database, any user with execution privileges can invoke the function. Let's take a look at a function to give you an idea of how they work.
In this example, the function is used to round a given number to the nearest quarter. This function works well for accepting a decimal value for labor hours and ...