1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Add PL/pgSQL SQLSTATE and SQLERRM support which sets these values on

error.

Pavel Stehule
This commit is contained in:
Bruce Momjian
2005-05-26 00:16:31 +00:00
parent 8c792fe9cb
commit 38af680ad5
6 changed files with 133 additions and 17 deletions

View File

@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.67 2005/04/19 03:55:43 momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.68 2005/05/26 00:16:31 momjian Exp $
-->
<chapter id="plpgsql">
@ -2007,12 +2007,13 @@ END LOOP;
</indexterm>
<para>
By default, any error occurring in a <application>PL/pgSQL</>
function aborts execution of the function, and indeed of the
surrounding transaction as well. You can trap errors and recover
from them by using a <command>BEGIN</> block with an
<literal>EXCEPTION</> clause. The syntax is an extension of the
normal syntax for a <command>BEGIN</> block:
Any error occurring in <application>PL/pgSQL</> sets variables
<varname>SQLSTATE</> and <varname>SQLERRM</>, and, by default,
aborts execution of the function, and indeed of the surrounding
transaction as well. You can trap errors and recover from them by
using a <command>BEGIN</> block with an <literal>EXCEPTION</>
clause. The syntax is an extension of the normal syntax for a
<command>BEGIN</> block:
<synopsis>
<optional> &lt;&lt;<replaceable>label</replaceable>&gt;&gt; </optional>