Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fdf067c

Browse files
committed
ELSEIF PL/PgSQL doc patch.
Klaus Reger
1 parent e6ba921 commit fdf067c

File tree

1 file changed

+41
-7
lines changed

1 file changed

+41
-7
lines changed

doc/src/sgml/plsql.sgml

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/plsql.sgml,v 2.32 2001/05/17 21:50:16 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/Attic/plsql.sgml,v 2.33 2001/05/22 13:52:27 momjian Exp $
33
-->
44

55
<chapter id="plpgsql">
@@ -880,12 +880,11 @@ RETURN <replaceable>expression</replaceable>
880880
<title>Conditional Control: IF statements</title>
881881

882882
<para>
883-
<function>IF</function> statements let you take action
884-
according to certain conditions. PL/pgSQL has three forms of
885-
IF: IF-THEN, IF-THEN-ELSE, IF-THEN-ELSE IF. NOTE: All
886-
PL/pgSQL IF statements need a corresponding <function>END
887-
IF</function> statement. In ELSE-IF statements you need two:
888-
one for the first IF and one for the second (ELSE IF).
883+
<function>IF</function> statements let you execute commands based on
884+
certain conditions. PL/PgSQL has four forms of IF: IF-THEN, IF-THEN-ELSE,
885+
IF-THEN-ELSE IF, IF-THEN-ELSIF-THEN-ELSE. NOTE: All PL/PgSQL IF statements need
886+
a corresponding <function>END IF</function> clause. With ELSE-IF statements,
887+
you need two: one for the first IF and one for the second (ELSE IF).
889888
</para>
890889

891890
<variablelist>
@@ -979,6 +978,41 @@ END IF;
979978
</para>
980979
</listitem>
981980
</varlistentry>
981+
982+
<varlistentry>
983+
<term>
984+
IF-THEN-ELSIF-ELSE
985+
</term>
986+
987+
<listitem>
988+
<para>
989+
IF-THEN-ELSIF-ELSE allows you test multiple conditions
990+
in one statement. Internally it is handled as nested
991+
IF-THEN-ELSE-IF-THEN commands. The optional ELSE
992+
branch is executed when none of the conditions are met.
993+
</para>
994+
995+
<para>
996+
Here is an example:
997+
</para>
998+
999+
<programlisting>
1000+
IF number = 0 THEN
1001+
result := ''zero'';
1002+
ELSIF number &lt; 0 THEN
1003+
result := ''negative'';
1004+
ELSIF number &gt; 0 THEN
1005+
result := ''negative'';
1006+
ELSE
1007+
-- now it seems to be NULL
1008+
result := ''NULL'';
1009+
END IF;
1010+
</programlisting>
1011+
</para>
1012+
</listitem>
1013+
</varlistentry>
1014+
1015+
9821016
</variablelist>
9831017
</sect3>
9841018

0 commit comments

Comments
 (0)