Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit82fde1a

Browse files
committed
Add note pointing out the difference in semantics between Oracle and
plpgsql EXCEPTION blocks.
1 parent35a5fb6 commit82fde1a

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

‎doc/src/sgml/plpgsql.sgml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.44 2004/08/0800:50:58 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.45 2004/08/0822:40:46 tgl Exp $
33
-->
44

55
<chapter id="plpgsql">
@@ -2647,7 +2647,7 @@ show errors;
26472647
<para>
26482648
The <literal>show errors</literal> command does not exist in
26492649
<productname>PostgreSQL</>, and is not needed since errors are
2650-
reported automatically.
2650+
reported automatically.
26512651
</para>
26522652
</listitem>
26532653
</itemizedlist>
@@ -3009,7 +3009,8 @@ $$ LANGUAGE plpgsql;
30093009
<para>
30103010
The exception names supported by <application>PL/pgSQL</> are
30113011
different from Oracle's. The set of built-in exception names
3012-
is much larger (see <xref linkend="errcodes-appendix">).
3012+
is much larger (see <xref linkend="errcodes-appendix">). There
3013+
is not currently a way to declare user-defined exception names.
30133014
</para>
30143015
</callout>
30153016
</calloutlist>
@@ -3032,6 +3033,38 @@ $$ LANGUAGE plpgsql;
30323033
<productname>PostgreSQL</productname>.
30333034
</para>
30343035

3036+
<sect3 id="plpgsql-porting-exceptions">
3037+
<title>Implicit Rollback after Exceptions</title>
3038+
3039+
<para>
3040+
In <application>PL/pgSQL</>, when an exception is caught by an
3041+
<literal>EXCEPTION</> clause, all database changes since the block's
3042+
<literal>BEGIN</> are automatically rolled back. That is, the behavior
3043+
is equivalent to what you'd get in Oracle with
3044+
3045+
<programlisting>
3046+
BEGIN
3047+
SAVEPOINT s1;
3048+
... code here ...
3049+
EXCEPTION
3050+
WHEN ... THEN
3051+
ROLLBACK TO s1;
3052+
... code here ...
3053+
WHEN ... THEN
3054+
ROLLBACK TO s1;
3055+
... code here ...
3056+
END;
3057+
</programlisting>
3058+
3059+
If you are translating an Oracle procedure that uses
3060+
<command>SAVEPOINT</> and <command>ROLLBACK TO</> in this style,
3061+
your task is easy: just omit the <command>SAVEPOINT</> and
3062+
<command>ROLLBACK TO</>. If you have a procedure that uses
3063+
<command>SAVEPOINT</> and <command>ROLLBACK TO</> in a different way
3064+
then some actual thought will be required.
3065+
</para>
3066+
</sect3>
3067+
30353068
<sect3>
30363069
<title><command>EXECUTE</command></title>
30373070

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp