What is a user-defined function?
What is a user-defined function?
User defined function is a small program that can perform some operations defined by the user. Database languages like SQL has many built in functions like he functions used for different arithmetic functions which can be called by the user at any time to perform arithmetic operations. But in addition to that, users can define their own functions. Users can then pass on values to these functions to perform user defined functions. For example a user can pass two values to a function to add them, then multiply them and then find their average and return a value. This can be done by passing two values a and b to a function “ “fcn” in the form fcn(a, b). Then different arithmetic operations are performed as follows:
Add = a + b;
Multiply = a*b;
Average = (Add + Multiply)/2
The function can then return either of the three values i.e. Add, Multiply or Average.