Calling a UDR in the FOREACH Loop

In general, use these guidelines for calling another UDR from an SPL routine:
  • To call a user-defined procedure, use EXECUTE PROCEDURE procedure name.
  • To call a user-defined function, use EXECUTE FUNCTION function name (or EXECUTE PROCEDURE function name if the user-defined function was created with the CREATE PROCEDURE statement).

If you use EXECUTE PROCEDURE, the database server looks first for a user-defined procedure of the name you specify. If it finds the procedure, the database server executes it. If it does not find the procedure, it looks for a user-defined function of the same name to execute. If the database server finds neither a function nor a procedure, it issues an error message. If you use EXECUTE FUNCTION, the database server looks for a user-defined function of the name you specify. If it does not find a function of that name, the database server issues an error message.

An SPL function can return zero (0) or more values or rows.

The data type and count of each variable in the variable list must match each value that the function returns.

Related Statements