skip to main content
Designing and coding the IP : User defined scalar functions : Overloading of scalar functions
 

Overloading of scalar functions

Overloading of scalar function definition can be done based on the number of arguments. If you are interested in returning different types of result values based on the number of arguments being passed, you can define multiple definitions for the same scalar function name. For example:
{"EMPLOYEE", func_emp_name, XO_TYPE_VARCHAR, 1},
{"EMPLOYEE", func_emp_id, XO_TYPE_INTEGER, 2},
If the query calls employee(‘333-222-000’), the func_emp_name() routine is invoked and the result would be returned as a STRING to the user. If the query calls employee('Pooh Bear', 234), func_emp_id() is invoked and the result is returned as an INTEGER.
Note: Overloading a function based on the type of the input arguments is not currently supported.