--- title: 'PostgreSQL Exception' page_title: 'PostgreSQL Exception' page_description: 'In this tutorial, you will learn how to catch and handle exceptions in PL/pgSQL.' prev_url: 'https://www.postgresqltutorial.com/postgresql-plpgsql/postgresql-exception/' ogImage: 'https://www.postgresqltutorial.com//postgresqltutorial/film_table.png' updatedOn: '2024-03-19T08:01:05+00:00' enableTableOfContents: true previousLink: title: 'PL/pgSQL Continue Statement' slug: 'postgresql-plpgsql/pl-pgsql-continue' nextLink: title: 'PostgreSQL Create Function Statement' slug: 'postgresql-plpgsql/postgresql-create-function' --- **Summary**: in this tutorial, you will learn how to catch and handle exceptions in PL/pgSQL. ## Introduction to the PL/pgSQL Exception clause When an error occurs within a [block](plpgsql-block-structure), PostgreSQL will abort the execution of that block as well as the surrounding transaction. To recover from the error, you can use the `exception` clause in the `begin...end` block. Here’s the syntax of the `exception` clause: ```sql <