7.3Stored Functions

A stored function is executable code stored in the database metadata for execution on the server. It can be called by other stored functions (including itself), procedures, triggers, and client applications through DML statements. A function that calls itself is known as recursive.

Unlike stored procedures, stored functions always return one scalar value. To return a value from a stored function, use the RETURN statement, which immediately terminates the function.

7.3.1Creating a Stored Function

For information about creating stored functions, see CREATE FUNCTION in Chapter 5, Data Definition (DDL) Statements.

7.3.2Modifying a Stored Function

For information about modifying stored functions, see ALTER FUNCTION, CREATE OR ALTER FUNCTION, RECREATE FUNCTION.

7.3.3Dropping a Stored Function

For information about dropping (deleting) stored functions, see DROP FUNCTION.