ELSEIF PL/PgSQL doc patch.
authorBruce Momjian
Tue, 22 May 2001 13:52:27 +0000 (13:52 +0000)
committerBruce Momjian
Tue, 22 May 2001 13:52:27 +0000 (13:52 +0000)
Klaus Reger

doc/src/sgml/plsql.sgml

index b30bca80f7de8c985f40dddd31b6972839b9f8a8..60d6b62be3c61ddae0817a1b1e679a90477d3d9e 100644 (file)
@@ -1,5 +1,5 @@
 
 
  
@@ -880,12 +880,11 @@ RETURN expression
     Conditional Control: IF statements
 
     
-     IF statements let you take action
-     according to certain conditions. PL/pgSQL has three forms of
-     IF: IF-THEN, IF-THEN-ELSE, IF-THEN-ELSE IF. NOTE: All
-     PL/pgSQL IF statements need a corresponding END
-     IF statement. In ELSE-IF statements you need two:
-     one for the first IF and one for the second (ELSE IF).
+   IF statements let you execute commands based on
+      certain conditions. PL/PgSQL has four forms of IF: IF-THEN, IF-THEN-ELSE,
+      IF-THEN-ELSE IF, IF-THEN-ELSIF-THEN-ELSE. NOTE: All PL/PgSQL IF statements need
+   a corresponding END IF clause. With ELSE-IF statements,
+      you need two: one for the first IF and one for the second (ELSE IF).
     
 
     
@@ -979,6 +978,41 @@ END IF;
        
       
      
+
+     
+      
+       IF-THEN-ELSIF-ELSE
+      
+
+      
+       
+        IF-THEN-ELSIF-ELSE allows you test multiple conditions
+        in one statement. Internally it is handled as nested 
+        IF-THEN-ELSE-IF-THEN commands. The optional ELSE
+        branch is executed when none of the conditions are met.
+       
+
+       
+        Here is an example:
+       
+
+
+IF number = 0 THEN
+    result := ''zero'';
+ELSIF number < 0 THEN
+    result := ''negative'';
+ELSIF number > 0 THEN 
+    result := ''negative'';
+ELSE
+    -- now it seems to be NULL
+    result := ''NULL'';
+END IF;
+
+       
+      
+     
+
+