Selecting User-Defined Function Expressions

User-defined functions extend the range of functions that are available to you and allow you to perform a subquery on each row that you select.

The following example calls the get_orders( ) user-defined function for each customer_num and displays the returned value under the n_orders label:
SELECT customer_num, lname, get_orders(customer_num) n_orders
      FROM customer;

If an SPL routine in a SELECT statement contains certain SQL statements, the database server returns an error. For information on which SQL statements cannot be used in an SPL routine that is called within a query, see Restrictions on SPL Routines in Data-Manipulation Statements.

For the complete syntax of user-defined function expressions, see User-Defined Functions.