A user-defined function
EXEC SQL execute function items_pct(\"HSK\")
into :manuf_percent;
If you do not know the name of the user-defined function until run time, you must dynamically execute the function. Dynamic execution of a user-defined function is a similar dynamic execution of a SELECT statement (Handling an unknown select list). Both the SELECT and the user-defined function return values to the program.
- If the user-defined function returns only one row, use PREPARE and EXECUTE INTO to execute the EXECUTE FUNCTION statement. This type of user-defined function is often called a noncursor function.
- If the user-defined function returns more than one row, you must
declare a function cursor to execute the EXECUTE FUNCTION statement.
This type of user-defined function is often called a cursor function. A cursor function that is written in SPL (an SPL function) has the WITH RESUME clause in its RETURN statement. A cursor function that is written in an external language such as C is an iterator function.