Hard to Get

--人生在世 难得二字

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

PL/SQL Best Practices [10][If Statements]-Flatten Nested IFs

Avoid Unnecessary Nested IFs
The following statements are equivalent. The flat structure expresses the logic more clearly and with less code.
Nested:

 1IF <condition1> 
 2THEN 
 3    
 4ELSE 
 5   IF <condition2> 
 6   THEN 
 7       
 8   ELSE 
 9      IF <condition3>
10      THEN 
11          
12      ELSE 
13         IF <condition4> 
14         THEN
15            
16         END IF;
17      END IF;
18   END IF;
19END IF;
20

Flat:

 1IF <condition1>
 2THEN
 3   
 4ELSIF <condition2>   
 5THEN
 6   
 7ELSIF <condition3>
 8THEN
 9   
10ELSIF <condition4>
11THEN
12   
13END IF;
posted on 2005-09-13 21:31  Del  阅读(111)  评论(0)    收藏  举报