Skip to content
Webinar Series: EDB Postgres Distributed • Oct 12 & 26 • Register Now

PostgreSQL Stored Procedures Tutorials and Examples

PostgreSQL allows you to extend its functionality with user defined functions by using various procedural languages such as PL/pgSQL, C, Perl, Python, and Tcl. These user defined functions are terms as Stored Procedures in PostgreSQL. Stored procedures allow you to create your custom functions and reuse them in applications or workflows in other databases.

Stored procedures in PostgreSQL: How to create a stored procedure and invoke it?

Moumita Ray11/15/2019

A stored procedure is basically a set of precompiled SQL and procedural statements (declarations, assignments, loops, etc.) that is stored on the database server and can be invoked using the SQL interface to perform a special operation.

Everything you need to know about Postgres stored procedures and functions 

Thom Brown12/6/2019

This article reviews the differences between stored procedures and functions in Postgres and the types of functionality they provide.

How to raise errors and report messages within stored procedures and functions

This article discusses the RAISE command for reporting errors, warnings, and other report messages within stored procedures and functions in PostgreSQL. Levels of error messages are covered along with settings for specifying their display to the clie ...

How to declare variables in PL/pgSQL stored procedures

This article covers how stored procedures can make use of variables to be more functional and useful. After defining PL/pgSQL, stored procedures, and variables, it provides examples of how variables can be used.

How to develop a user-defined function in PostgreSQL stored procedures

Tushar Ahuja12/19/2019

This article covers how to create user-defined functions using PL/pgSQL procedural language in PostgreSQL. It introduces user-defined functions and gives examples of their use in different scenarios: PL/pgSQL; User-defined functions and procedures; C ...

10 Examples of PostgreSQL Stored Procedures

Ranjeet Dhumal1/8/2020

A stored procedure is a set of structured queries and statements such as control statements and declarations. Here are ten examples of stored procedures that can be useful in different situations.

How to work with control structures in PostgreSQL stored procedures: Using IF, CASE, and LOOP statements

Arun Gavhane2/12/2020

This article reviews control structures that can be used in PostgreSQL stored procedures, with syntax and examples provided for each.

How to call PostgreSQL stored procedures from a PHP application

Abbas Butt2/19/2020

This tutorial provides instructions and an example for calling a PostgreSQL stored procedure from a PHP application.