File tree 2 files changed +18
-2
lines changed
2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 1
1
<!--
2
- $PostgreSQL: pgsql/doc/src/sgml/ref/begin.sgml,v 1.31 2004/08/01 17:32:13 tgl Exp $
2
+ $PostgreSQL: pgsql/doc/src/sgml/ref/begin.sgml,v 1.32 2004/08/08 01:48:31 momjian Exp $
3
3
PostgreSQL documentation
4
4
-->
5
5
@@ -100,6 +100,9 @@ BEGIN [ WORK | TRANSACTION ]
100
100
<para>
101
101
Issuing <command>BEGIN</> when already inside a transaction block will
102
102
provoke a warning message. The state of the transaction is not affected.
103
+ To nest transactions within a transaction block, use savepoints
104
+ (See <xref linkend="sql-start-transaction" endterm="sql-start-transaction-title">
105
+ for more information).
103
106
</para>
104
107
</refsect1>
105
108
Original file line number Diff line number Diff line change 1
1
<!--
2
- $PostgreSQL: pgsql/doc/src/sgml/ref/update.sgml,v 1.29 2004/06/09 19:08:13 tgl Exp $
2
+ $PostgreSQL: pgsql/doc/src/sgml/ref/update.sgml,v 1.30 2004/08/08 01:48:31 momjian Exp $
3
3
PostgreSQL documentation
4
4
-->
5
5
@@ -187,6 +187,19 @@ UPDATE employees SET sales_count = sales_count + 1 FROM accounts
187
187
<programlisting>
188
188
UPDATE employees SET sales_count = sales_count + 1 WHERE id =
189
189
(SELECT sales_person FROM accounts WHERE name = 'Acme Corporation');
190
+ </programlisting>
191
+
192
+ Attempt to insert a new stock item along with the quantity of stock. If
193
+ the item exists, update the stock count of the existing item. To do this,
194
+ use savepoints.
195
+ <programlisting>
196
+ BEGIN;
197
+ SAVEPOINT sp1;
198
+ INSERT INTO wines VALUES('Chateau Lafite 2003', '24');
199
+ -- Check for unique violation on name
200
+ ROLLBACK TO sp1;
201
+ UPDATE wines SET stock = stock + 24 WHERE winename='Chateau Lafite 2003';
202
+ COMMIT;
190
203
</programlisting>
191
204
</para>
192
205
</refsect1>
You can’t perform that action at this time.
0 commit comments