aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/plpgsql.sgml21
1 files changed, 19 insertions, 2 deletions
diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml
index 11246aa6534..45d3e43ed14 100644
--- a/doc/src/sgml/plpgsql.sgml
+++ b/doc/src/sgml/plpgsql.sgml
@@ -946,8 +946,8 @@ PREPARE <replaceable>statement_name</replaceable>(integer, integer) AS SELECT $1
database engine. The expression must yield a single value (possibly
a row value, if the variable is a row or record variable). The target
variable can be a simple variable (optionally qualified with a block
- name), a field of a row or record variable, or an element of an array
- that is a simple variable or field. Equal (<literal>=</literal>) can be
+ name), a field of a row or record target, or an element or slice of
+ an array target. Equal (<literal>=</literal>) can be
used instead of PL/SQL-compliant <literal>:=</literal>.
</para>
@@ -968,8 +968,25 @@ PREPARE <replaceable>statement_name</replaceable>(integer, integer) AS SELECT $1
<programlisting>
tax := subtotal * 0.06;
my_record.user_id := 20;
+my_array[j] := 20;
+my_array[1:3] := array[1,2,3];
+complex_array[n].realpart = 12.3;
</programlisting>
</para>
+
+ <para>
+ It's useful to know that what follows the assignment operator is
+ essentially treated as a <literal>SELECT</literal> command; as long
+ as it returns a single row and column, it will work. Thus for example
+ one can write something like
+<programlisting>
+total_sales := sum(quantity) from sales;
+</programlisting>
+ This provides an effect similar to the single-row <literal>SELECT
+ ... INTO</literal> syntax described in
+ <xref linkend="plpgsql-statements-sql-onerow"/>. However, that syntax
+ is more portable.
+ </para>
</sect2>
<sect2 id="plpgsql-statements-sql-noresult">