|
1 | 1 | <!-- |
2 | | -$Header: /cvsroot/pgsql/doc/src/sgml/plpgsql.sgml,v 1.3 2002/08/22 00:01:40 tgl Exp $ |
| 2 | +$Header: /cvsroot/pgsql/doc/src/sgml/plpgsql.sgml,v 1.4 2002/08/29 04:12:02 tgl Exp $ |
3 | 3 | --> |
4 | 4 |
|
5 | 5 | <chapter id="plpgsql"> |
@@ -852,58 +852,10 @@ SELECT INTO <replaceable>target</replaceable> <replaceable>expressions</replacea |
852 | 852 | </para> |
853 | 853 |
|
854 | 854 | <para> |
855 | | - There is a special variable named <literal>FOUND</literal> of |
856 | | - type <type>boolean</type>. The initial value of |
857 | | - <literal>FOUND</literal> is false; it is set to true when one of |
858 | | - the following events occurs: |
859 | | - <itemizedlist> |
860 | | - <listitem> |
861 | | - <para> |
862 | | -A SELECT INTO statement is executed, and it returns one or |
863 | | -more rows. |
864 | | - </para> |
865 | | - </listitem> |
866 | | - <listitem> |
867 | | - <para> |
868 | | -A UPDATE, INSERT, or DELETE statement is executed, and it |
869 | | -affects one or more rows. |
870 | | - </para> |
871 | | - </listitem> |
872 | | - <listitem> |
873 | | - <para> |
874 | | -A PERFORM statement is executed, and it discards one or more |
875 | | -rows. |
876 | | - </para> |
877 | | - </listitem> |
878 | | - <listitem> |
879 | | - <para> |
880 | | -A FETCH statement is executed, and it returns an additional |
881 | | -row. |
882 | | - </para> |
883 | | - </listitem> |
884 | | - <listitem> |
885 | | - <para> |
886 | | -A FOR statement is executed, and it iterates one or more |
887 | | -times. This applies to all three variants of the FOR statement |
888 | | -(integer FOR loops, record-set FOR loops, and dynamic |
889 | | -record-set FOR loops). <literal>FOUND</literal> is only set |
890 | | -when the FOR loop exits: inside the execution of the loop, |
891 | | -<literal>FOUND</literal> is not modified, although it may be |
892 | | -set by the execution of other statements. |
893 | | - </para> |
894 | | - </listitem> |
895 | | - </itemizedlist> |
896 | | - If none of these events occur, <literal>FOUND</literal> is set to |
897 | | - false. <literal>FOUND</literal> is a local variable; any changes |
898 | | - to it effect only the current <application>PL/pgSQL</application> |
899 | | - function. |
900 | | -</para> |
901 | | - |
902 | | -<para> |
903 | | - You can use <literal>FOUND</literal> immediately after a SELECT |
904 | | - INTO statement to determine whether the assignment was successful |
905 | | - (that is, at least one row was was returned by the SELECT |
906 | | - statement). For example: |
| 855 | + You can use <literal>FOUND</literal> immediately after a SELECT |
| 856 | + INTO statement to determine whether the assignment was successful |
| 857 | + (that is, at least one row was was returned by the SELECT |
| 858 | + statement). For example: |
907 | 859 |
|
908 | 860 | <programlisting> |
909 | 861 | SELECT INTO myrec * FROM EMP WHERE empname = myname; |
@@ -1116,6 +1068,58 @@ GET DIAGNOSTICS <replaceable>variable</replaceable> = <replaceable>item</replace |
1116 | 1068 | </programlisting> |
1117 | 1069 | </informalexample> |
1118 | 1070 | </para> |
| 1071 | + |
| 1072 | + <para> |
| 1073 | + There is a special variable named <literal>FOUND</literal> of |
| 1074 | + type <type>boolean</type>. <literal>FOUND</literal> starts out |
| 1075 | + false within each <application>PL/pgSQL</application> function. |
| 1076 | + It is set by each of the following types of statements: |
| 1077 | + <itemizedlist> |
| 1078 | + <listitem> |
| 1079 | + <para> |
| 1080 | +A SELECT INTO statement sets <literal>FOUND</literal> |
| 1081 | +true if it returns a row, false if no row is returned. |
| 1082 | + </para> |
| 1083 | + </listitem> |
| 1084 | + <listitem> |
| 1085 | + <para> |
| 1086 | +A PERFORM statement sets <literal>FOUND</literal> |
| 1087 | +true if it produces (discards) a row, false if no row is |
| 1088 | +produced. |
| 1089 | + </para> |
| 1090 | + </listitem> |
| 1091 | + <listitem> |
| 1092 | + <para> |
| 1093 | +UPDATE, INSERT, and DELETE statements set |
| 1094 | +<literal>FOUND</literal> true if at least one row is |
| 1095 | +affected, false if no row is affected. |
| 1096 | + </para> |
| 1097 | + </listitem> |
| 1098 | + <listitem> |
| 1099 | + <para> |
| 1100 | +A FETCH statement sets <literal>FOUND</literal> |
| 1101 | +true if it returns a row, false if no row is returned. |
| 1102 | + </para> |
| 1103 | + </listitem> |
| 1104 | + <listitem> |
| 1105 | + <para> |
| 1106 | +A FOR statement sets <literal>FOUND</literal> |
| 1107 | +true if it iterates one or more times, else false. |
| 1108 | +This applies to all three variants of the FOR statement |
| 1109 | +(integer FOR loops, record-set FOR loops, and dynamic |
| 1110 | +record-set FOR loops). <literal>FOUND</literal> is only set |
| 1111 | +when the FOR loop exits: inside the execution of the loop, |
| 1112 | +<literal>FOUND</literal> is not modified by the FOR statement, |
| 1113 | +although it may be changed by the execution of other |
| 1114 | +statements within the loop body. |
| 1115 | + </para> |
| 1116 | + </listitem> |
| 1117 | + </itemizedlist> |
| 1118 | + <literal>FOUND</literal> is a local variable; any changes |
| 1119 | + to it affect only the current <application>PL/pgSQL</application> |
| 1120 | + function. |
| 1121 | + </para> |
| 1122 | + |
1119 | 1123 | </sect2> |
1120 | 1124 | </sect1> |
1121 | 1125 |
|
|