liveBook · Manning

Database function

A database function is a named routine stored or executed in a database that accepts inputs and computes a result, often a scalar or table-valued result.

How 3 Manning books explain it

Just Use Postgres!

A database function is a stored routine that accepts inputs, performs computation or data operations, and returns a value or result within the database.

How it is used
Deploys reusable data-coupled business logic and multistep operations for applications, microservices, and database-backed APIs.
How deep it goes
Defines SQL functions and demonstrates parameters, return tables, conditionals, updates, exceptions, and replacement, without deep administration guidance.
Examples
Uses product-price lookup, pending shopping carts, item addition, checkout totals, and database-backed message APIs as examples.
What you can do after
Build it from scratch using CREATE OR REPLACE FUNCTION, call it from SQL, inspect returned rows, and centralize multistep data workflows.

Read how Just Use Postgres! explains database function →

PostgreSQL Mistakes and How to Avoid Them

A database function is a named routine stored in the database that accepts inputs and produces a result or side effect.

How it is used
Uses stored routines to return values or perform database-side actions while emphasizing ownership and execution privileges.
How deep it goes
Explains execution privileges through a destructive scenario but stops short of function syntax or internal implementation.
Examples
Uses reset_schema(), count(), and data type conversion functions as examples of side effects, NULL handling, and migration compatibility.
What you can do after
Operate database functions more safely by reviewing ownership, execution rights, side effects, NULL behavior, and migration compatibility.

Read how PostgreSQL Mistakes and How to Avoid Them explains database function →

Learn SQL in a Month of Lunches

A database function is a named database routine or SQL operation that computes and returns a value, optionally from supplied arguments.

How it is used
Uses SQL functions to calculate, select, filter, transform, and inspect database values.
How deep it goes
Explains function purpose, argument syntax, practical categories, efficiency cautions, and RDBMS variation without covering implementation internals.
Examples
Demonstrates spreadsheet totals, aggregate calculations, and UPPER or LOWER applied to California customer names.
What you can do after
Apply it via SQL to calculate, extract, filter, combine, convert, or format values while recognizing portability and efficiency issues.

Read how Learn SQL in a Month of Lunches explains database function →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.