Chapter 32. Stored Functions

32.1 Introduction

Stored functions show a strong resemblance to stored procedures: They are pieces of code consisting of SQL and procedural statements that are stored in the catalog and can be called from applications and SQL statements. However, a few differences exist:

• A stored function can have input parameters but does not have output parameters. The stored function itself is the output parameter. The next sections illustrate this with examples.

• After stored functions have been created, all kinds of expressions can invoke them in the same way they invoke the familiar scalar functions. Therefore, we do not call stored functions using a CALL statement.

• Stored functions must contain a RETURN statement. This ...

Get SQL for MySQL Developers: A Comprehensive Tutorial and Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.