mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
Improve UPDATE/DELETE WHERE CURRENT OF so that they can be used from plpgsql
with a plpgsql-defined cursor. The underlying mechanism for this is that the main SQL engine will now take "WHERE CURRENT OF $n" where $n is a refcursor parameter. Not sure if we should document that fact or consider it an implementation detail. Per discussion with Pavel Stehule.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.111 2007/06/11 15:08:32 tgl Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.112 2007/06/11 22:22:40 tgl Exp $ -->
|
||||
|
||||
<chapter id="plpgsql">
|
||||
<title><application>PL/pgSQL</application> - <acronym>SQL</acronym> Procedural Language</title>
|
||||
@ -2614,6 +2614,31 @@ MOVE <optional> <replaceable>direction</replaceable> { FROM | IN } </optional> <
|
||||
MOVE curs1;
|
||||
MOVE LAST FROM curs3;
|
||||
MOVE RELATIVE -2 FROM curs4;
|
||||
</programlisting>
|
||||
</para>
|
||||
</sect3>
|
||||
|
||||
<sect3>
|
||||
<title><literal>UPDATE/DELETE WHERE CURRENT OF</></title>
|
||||
|
||||
<synopsis>
|
||||
UPDATE <replaceable>table</replaceable> SET ... WHERE CURRENT OF <replaceable>cursor</replaceable>;
|
||||
DELETE FROM <replaceable>table</replaceable> WHERE CURRENT OF <replaceable>cursor</replaceable>;
|
||||
</synopsis>
|
||||
|
||||
<para>
|
||||
When a cursor is positioned on a table row, that row can be updated
|
||||
or deleted using the cursor to identify the row. Note that this
|
||||
only works for simple (non-join, non-grouping) cursor queries.
|
||||
For additional information see the
|
||||
<xref linkend="sql-declare" endterm="sql-declare-title">
|
||||
reference page.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
An example:
|
||||
<programlisting>
|
||||
UPDATE foo SET dataval = myval WHERE CURRENT OF curs1;
|
||||
</programlisting>
|
||||
</para>
|
||||
</sect3>
|
||||
|
Reference in New Issue
Block a user