7.3Stored Functions

A stored function is executable code stored in the database metadata for execution on the server. A stored function can be called by other stored functions (including itself), procedures, triggers and client applications. 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 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, in Chapter Data Definition (DDL) Statements.

7.3.3Deleting a Stored Function

For information about deleting stored procedures, see DROP FUNCTION in Chapter Data Definition (DDL) Statements.