diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-29 04:12:03 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-29 04:12:03 +0000 |
commit | 99fd5cbd410c29381d2ffdfd98705c68fe99fbe3 (patch) | |
tree | ee7cb47fb333ab4967739c5787d2a926b8ec13a2 /doc/src | |
parent | 5241a6259ff0a4a12d7659b25310f0987b51f211 (diff) | |
download | postgresql-99fd5cbd410c29381d2ffdfd98705c68fe99fbe3.tar.gz postgresql-99fd5cbd410c29381d2ffdfd98705c68fe99fbe3.zip |
FOUND patch was a bit over-enthusiastic: SQL commands that are not
INSERT, UPDATE, or DELETE shouldn't change FOUND. IMHO anyway.
Also, try to make documentation a little clearer.
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/plpgsql.sgml | 110 |
1 files changed, 57 insertions, 53 deletions
diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml index 51b85b9d85c..acdd8a4f4dc 100644 --- a/doc/src/sgml/plpgsql.sgml +++ b/doc/src/sgml/plpgsql.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/plpgsql.sgml,v 1.3 2002/08/22 00:01:40 tgl Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/plpgsql.sgml,v 1.4 2002/08/29 04:12:02 tgl Exp $ --> <chapter id="plpgsql"> @@ -852,58 +852,10 @@ SELECT INTO <replaceable>target</replaceable> <replaceable>expressions</replacea </para> <para> - There is a special variable named <literal>FOUND</literal> of - type <type>boolean</type>. The initial value of - <literal>FOUND</literal> is false; it is set to true when one of - the following events occurs: - <itemizedlist> - <listitem> - <para> - A SELECT INTO statement is executed, and it returns one or - more rows. - </para> - </listitem> - <listitem> - <para> - A UPDATE, INSERT, or DELETE statement is executed, and it - affects one or more rows. - </para> - </listitem> - <listitem> - <para> - A PERFORM statement is executed, and it discards one or more - rows. - </para> - </listitem> - <listitem> - <para> - A FETCH statement is executed, and it returns an additional - row. - </para> - </listitem> - <listitem> - <para> - A FOR statement is executed, and it iterates one or more - times. This applies to all three variants of the FOR statement - (integer FOR loops, record-set FOR loops, and dynamic - record-set FOR loops). <literal>FOUND</literal> is only set - when the FOR loop exits: inside the execution of the loop, - <literal>FOUND</literal> is not modified, although it may be - set by the execution of other statements. - </para> - </listitem> - </itemizedlist> - If none of these events occur, <literal>FOUND</literal> is set to - false. <literal>FOUND</literal> is a local variable; any changes - to it effect only the current <application>PL/pgSQL</application> - function. - </para> - - <para> - You can use <literal>FOUND</literal> immediately after a SELECT - INTO statement to determine whether the assignment was successful - (that is, at least one row was was returned by the SELECT - statement). For example: + You can use <literal>FOUND</literal> immediately after a SELECT + INTO statement to determine whether the assignment was successful + (that is, at least one row was was returned by the SELECT + statement). For example: <programlisting> SELECT INTO myrec * FROM EMP WHERE empname = myname; @@ -1116,6 +1068,58 @@ GET DIAGNOSTICS <replaceable>variable</replaceable> = <replaceable>item</replace </programlisting> </informalexample> </para> + + <para> + There is a special variable named <literal>FOUND</literal> of + type <type>boolean</type>. <literal>FOUND</literal> starts out + false within each <application>PL/pgSQL</application> function. + It is set by each of the following types of statements: + <itemizedlist> + <listitem> + <para> + A SELECT INTO statement sets <literal>FOUND</literal> + true if it returns a row, false if no row is returned. + </para> + </listitem> + <listitem> + <para> + A PERFORM statement sets <literal>FOUND</literal> + true if it produces (discards) a row, false if no row is + produced. + </para> + </listitem> + <listitem> + <para> + UPDATE, INSERT, and DELETE statements set + <literal>FOUND</literal> true if at least one row is + affected, false if no row is affected. + </para> + </listitem> + <listitem> + <para> + A FETCH statement sets <literal>FOUND</literal> + true if it returns a row, false if no row is returned. + </para> + </listitem> + <listitem> + <para> + A FOR statement sets <literal>FOUND</literal> + true if it iterates one or more times, else false. + This applies to all three variants of the FOR statement + (integer FOR loops, record-set FOR loops, and dynamic + record-set FOR loops). <literal>FOUND</literal> is only set + when the FOR loop exits: inside the execution of the loop, + <literal>FOUND</literal> is not modified by the FOR statement, + although it may be changed by the execution of other + statements within the loop body. + </para> + </listitem> + </itemizedlist> + <literal>FOUND</literal> is a local variable; any changes + to it affect only the current <application>PL/pgSQL</application> + function. + </para> + </sect2> </sect1> |