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 $ -->
2
2
3
3
<chapter id="plpgsql">
4
4
<title><application>PL/pgSQL</application> - <acronym>SQL</acronym> Procedural Language</title>
@@ -1076,8 +1076,8 @@ tax := subtotal * 0.06;
1076
1076
</indexterm>
1077
1077
1078
1078
<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
1081
1081
variable, or list of scalar variables. This is done by:
1082
1082
1083
1083
<synopsis>
@@ -1126,23 +1126,24 @@ SELECT INTO <optional>STRICT</optional> <replaceable>target</replaceable> <repla
1126
1126
<replaceable>target</replaceable> will be set to the first row
1127
1127
returned by the query, or if the query returned no rows,
1128
1128
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:
1132
1134
1133
1135
<programlisting>
1134
- SELECT INTO STRICT myrec * FROM emp WHERE empname = myname;
1136
+ SELECT INTO myrec * FROM emp WHERE empname = myname;
1135
1137
IF NOT FOUND THEN
1136
1138
RAISE EXCEPTION 'employee % not found', myname;
1137
1139
END IF;
1138
1140
</programlisting>
1139
1141
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
1142
1143
return exactly one row or a run-time error will be thrown, either
1143
1144
<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 :
1146
1147
1147
1148
<programlisting>
1148
1149
BEGIN;
@@ -1154,11 +1155,17 @@ BEGIN;
1154
1155
RAISE EXCEPTION 'employee % not unique', myname;
1155
1156
END;
1156
1157
</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.
1160
1160
</para>
1161
1161
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
+
1162
1169
</sect2>
1163
1170
1164
1171
<sect2 id="plpgsql-statements-perform">
@@ -1987,7 +1994,7 @@ END LOOP <optional> <replaceable>label</replaceable> </optional>;
1987
1994
the loop. If the <literal>BY</> clause isn't specified the iteration
1988
1995
step is 1 otherwise it's the value specified in the <literal>BY</>
1989
1996
clause. If <literal>REVERSE</> is specified then the step value is
1990
- considered negative.
1997
+ considered negative.
1991
1998
</para>
1992
1999
1993
2000
<para>
@@ -2764,7 +2771,7 @@ RAISE EXCEPTION 'Nonexistent ID --> %', user_id;
2764
2771
<para>
2765
2772
Data type <type>name</type>; the name of the table that caused the trigger
2766
2773
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.
2768
2775
</para>
2769
2776
</listitem>
2770
2777
</varlistentry>
@@ -2774,7 +2781,7 @@ RAISE EXCEPTION 'Nonexistent ID --> %', user_id;
2774
2781
<listitem>
2775
2782
<para>
2776
2783
Data type <type>name</type>; the name of the table that
2777
- caused the trigger invocation.
2784
+ caused the trigger invocation.
2778
2785
</para>
2779
2786
</listitem>
2780
2787
</varlistentry>
@@ -2784,7 +2791,7 @@ RAISE EXCEPTION 'Nonexistent ID --> %', user_id;
2784
2791
<listitem>
2785
2792
<para>
2786
2793
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.
2788
2795
</para>
2789
2796
</listitem>
2790
2797
</varlistentry>
0 commit comments