Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2042768
  • 博文数量: 519
  • 博客积分: 10070
  • 博客等级: 上将
  • 技术积分: 3985
  • 用 户 组: 普通用户
  • 注册时间: 2006-05-29 14:05
个人简介

只问耕耘

文章分类

全部博文(519)

文章存档

2016年(1)

2013年(5)

2011年(46)

2010年(220)

2009年(51)

2008年(39)

2007年(141)

2006年(16)

我的朋友

分类: Oracle

2010-04-23 16:28:11

Oracle/PLSQL: FOR Loop

--------------------------------------------------------------------------------

The syntax for the FOR Loop is:

FOR loop_counter IN [REVERSE] lowest_number..highest_number
LOOP
     {.statements.}
END LOOP;

You would use a FOR Loop when you want to execute the loop body a fixed number of times.

 

Let's take a look at an example.

FOR Lcntr IN 1..20
LOOP
     LCalc := Lcntr * 31;
END LOOP;

This example will loop 20 times. The counter will start at 1 and end at 20.

 

The FOR Loop can also loop in reverse. For example:

FOR Lcntr IN REVERSE 1..15
LOOP
     LCalc := Lcntr * 31;
END LOOP;

This example will loop 15 times. The counter will start at 15 and end at 1. (loops backwards)

阅读(1450) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~