1- <!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.96 2006/06/15 18:02:22 momjian Exp $ -->
1+ <!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.97 2006/06/16 23:29:26 tgl Exp $ -->
22
33<chapter id="plpgsql">
44 <title><application>PL/pgSQL</application> - <acronym>SQL</acronym> Procedural Language</title>
@@ -1076,8 +1076,8 @@ tax := subtotal * 0.06;
10761076 </indexterm>
10771077
10781078 <para>
1079- The result of a <command>SELECT</command> command yielding multiple columns (but
1080- only one row) can be assigned to a record variable, row-type
1079+ The result of a <command>SELECT</command> command yielding multiple
1080+ columns (but only one row) can be assigned to a record variable, row-type
10811081 variable, or list of scalar variables. This is done by:
10821082
10831083<synopsis>
@@ -1126,23 +1126,24 @@ SELECT INTO <optional>STRICT</optional> <replaceable>target</replaceable> <repla
11261126 <replaceable>target</replaceable> will be set to the first row
11271127 returned by the query, or if the query returned no rows,
11281128 null values are assigned. (Note that <quote>the first row</> is not
1129- well-defined unless you've used <literal>ORDER BY</>.)
1130- You can check the special <literal>FOUND</literal> variable to
1131- determine if any rows were found:
1129+ well-defined unless you've used <literal>ORDER BY</>.) Any result rows
1130+ after the first row are discarded.
1131+ You can check the special <literal>FOUND</literal> variable (see
1132+ <xref linkend="plpgsql-statements-diagnostics">) to
1133+ determine whether a row was returned:
11321134
11331135<programlisting>
1134- SELECT INTO STRICT myrec * FROM emp WHERE empname = myname;
1136+ SELECT INTO myrec * FROM emp WHERE empname = myname;
11351137IF NOT FOUND THEN
11361138 RAISE EXCEPTION 'employee % not found', myname;
11371139END IF;
11381140</programlisting>
11391141
1140- <para>
1141- If the <literal>STRICT</literal> option is specified, a query must
1142+ If the <literal>STRICT</literal> option is specified, the query must
11421143 return exactly one row or a run-time error will be thrown, either
11431144 <literal>NO_DATA_FOUND</> (no rows) or <literal>TOO_MANY_ROWS</>
1144- (more than one row). You can must use exception blocks to determine
1145- the number of rows generated by the query :
1145+ (more than one row). You can use an exception block if you wish
1146+ to catch the error, for example :
11461147
11471148<programlisting>
11481149BEGIN;
@@ -1154,11 +1155,17 @@ BEGIN;
11541155 RAISE EXCEPTION 'employee % not unique', myname;
11551156END;
11561157</programlisting>
1157- Only <command>SELECT INTO STRICT</command> allows you to check if more
1158- than one row was retrieved. <command>SELECT INTO STRICT</command>
1159- matches Oracle's PL/SQL <command>SELECT INTO</command> behavior.
1158+ Successful execution of <command>SELECT INTO STRICT</command>
1159+ always sets <literal>FOUND</literal> to true.
11601160 </para>
11611161
1162+ <note>
1163+ <para>
1164+ <command>SELECT INTO STRICT</command> matches the behavior of
1165+ Oracle PL/SQL's <command>SELECT INTO</command> statement.
1166+ </para>
1167+ </note>
1168+
11621169 </sect2>
11631170
11641171 <sect2 id="plpgsql-statements-perform">
@@ -1987,7 +1994,7 @@ END LOOP <optional> <replaceable>label</replaceable> </optional>;
19871994 the loop. If the <literal>BY</> clause isn't specified the iteration
19881995 step is 1 otherwise it's the value specified in the <literal>BY</>
19891996 clause. If <literal>REVERSE</> is specified then the step value is
1990- considered negative.
1997+ considered negative.
19911998 </para>
19921999
19932000 <para>
@@ -2764,7 +2771,7 @@ RAISE EXCEPTION 'Nonexistent ID --> %', user_id;
27642771 <para>
27652772 Data type <type>name</type>; the name of the table that caused the trigger
27662773 invocation. This is now deprecated, and could disappear in a future
2767- release. Use <literal>TG_TABLE_NAME</> instead.
2774+ release. Use <literal>TG_TABLE_NAME</> instead.
27682775 </para>
27692776 </listitem>
27702777 </varlistentry>
@@ -2774,7 +2781,7 @@ RAISE EXCEPTION 'Nonexistent ID --> %', user_id;
27742781 <listitem>
27752782 <para>
27762783 Data type <type>name</type>; the name of the table that
2777- caused the trigger invocation.
2784+ caused the trigger invocation.
27782785 </para>
27792786 </listitem>
27802787 </varlistentry>
@@ -2784,7 +2791,7 @@ RAISE EXCEPTION 'Nonexistent ID --> %', user_id;
27842791 <listitem>
27852792 <para>
27862793 Data type <type>name</type>; the name of the schema of the
2787- table that caused the trigger invocation.
2794+ table that caused the trigger invocation.
27882795 </para>
27892796 </listitem>
27902797 </varlistentry>
0 commit comments