Chapter 31. Stored Functions

Introduction

Stored functions show a strong resemblance to stored procedures. Stored functions are also 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, there are a few differences.

A stored function can have input parameters but does not have output parameters. The stored function itself is the output parameter. In the next sections, we use examples to illustrate this.

After stored functions have been created, they can be called within several expressions, just as the familiar scalar functions. Therefore, we do not call stored functions using a CALL statement.

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

Get Introduction to SQL: Mastering the Relational Database Language, Fourth Edition/20th Anniversary Edition 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.