1. Basic loop

loop
/* statements */
end loop;

2. While loop

while a > b loop
/* statements */
end loop

  

3. For loop

for i in 1..1000 loop
insert into a values(i,i*2);
end loop; for i in reverse 1..1000 loop
insert into a values(i,i*2);
end loop;

  

4. Cursor for loop

for rec in (select col_1, col_2 from table_a) loop
/*Statements, use rec.col_1 and rec.col_2 */
end loop; for rec in cursor_name loop
/*Statements, use rec.col_1 and rec.col_2 */
end loop; for rec in cursor_name(cursor_param_1, cursor_param_2...) loop
/*Statements, use rec.col_1 and rec.col_2 */
end loop;

  

5. Labels

  Each of the loops can be labeled

<<label_name>>
loop
....
end loop label_name;

  When a loop is labeled, the exit statement can then refer to that label:

begin
<<i_loop>> for i in 1 .. 10 loop
<<j_loop>> for j in 1 .. 10 loop
dbms_output.put(to_char(j, '999'));
exit j_loop when j=i;
end loop;
dbms_output.new_line;
end loop;
end;

  

6. exit

exit;
exit when foo > bar; exit label_name;
exit label_name when foo > bar;

Loops with PL/SQL的更多相关文章

  1. pl/sql tutorial

    http://plsql-tutorial.com/plsql-procedures.htm What is PL/SQL? PL/SQL stands for Procedural Language ...

  2. postgreSQL PL/SQL编程学习笔记(二)

    Control Structures of PL/SQL Control structures are probably the most useful (and important) part of ...

  3. PL/SQL Transaction Control

    PL/SQL 基础 ( 下 )   1. PL/SQL中的 SQL语句 - END语句与COMMIT等内容,没有任何关系. - PL/SQL does not directly support dat ...

  4. PL/SQL : Procedural Language / Structual Query Language and it is an exrension to SQL.

    SQL is not very flexible and it cannot be made to react differently to differing sutuations easily. ...

  5. oracle PL/SQL(procedure language/SQL)程序设计--控制结构(if else )

    IF逻辑结构:IF-THEN-END IFIF-THEN-ELSE-END IFIF-THEN-ELSIF-END IF 语法 IF condition THEN  statements;[ELSIF ...

  6. 转://Oracle PL/SQL 优化与调整 -- Bulk 说明

    一. Bulk 概述 本来只想测试一下Bulk Collect 和update性能的,但发现Bulk 的东西还是很多的,在OTN上搜了一些,整理如下. 1.1 Bulk Binding 和 Bulk ...

  7. 利用pl/sql执行计划评估SQL语句的性能简析

    一段SQL代码写好以后,可以通过查看SQL的执行计划,初步预测该SQL在运行时的性能好坏,尤其是在发现某个SQL语句的效率较差时,我们可以通过查看执行计划,分析出该SQL代码的问题所在.  那么,作为 ...

  8. PL/SQL控制结构

    顺序结构 按先后顺序 分支判断结构 IF语句 IF condition THEN statements; [ELSIF condition THEN statements;] [ELSE statem ...

  9. PL/SQL DEVELOPER执行计划的查看

    这里,我学到的一个很重要的东西,就是用PL/SQL DEVELOPER去看一条SELECT语句的执行计划,执行计划里面可以看到这条SELECT语句的开销.I/O操作开销等数值,可以很清晰地看到语句各个 ...

随机推荐

  1. Sum It Up---poj1564(dfs)

    题目链接:http://poj.org/problem?id=1564 给出m个数,求出和为n的组合方式:并按从大到小的顺序输出: 简单的dfs但是看了代码才会: #include <cstdi ...

  2. Navicat运行sql文件报错out of memory

    下载并安装mysql workbench:

  3. Hadoop集群完全分布式坏境搭建

    前言 上一篇我们讲解了Hadoop单节点的安装,并且已经通过VMware安装了一台CentOS 6.8的Linux系统,咱们本篇的目标就是要配置一个真正的完全分布式的Hadoop集群,闲言少叙,进入本 ...

  4. React Native教程

    React Native 中文网  http://reactnative.cn/ 相关资料======================= React-Native学习指南 https://github ...

  5. Executor框架与Thread

    Executor将线程的创建和线程的执行解耦,比较下面两个例子: 1:TaskExecutionWebServer.java package chapter06; import java.io.IOE ...

  6. mac终端显示日历信息命令

    cal 命令: 用法: usage: cal [-jy] [[month] year] cal [-j] [-m month] [year] ncal [-Jjpwy] [-s country_cod ...

  7. Ubuntu 16.04安装Eclipse并创建桌面快捷方式

    系统:Ubuntu 16.04 JDK版本:1.8.0_121 1.官网下载eclipse,我的版本是eclipse-jee-neon-2-linux-gtk-x86_64.tar.gz,只要JDK版 ...

  8. 多口USB HUB信号延长器 USBX-M200(针对于A客户使用时很棒吧)

    大家都知道A客户是不允许在设备里面出现无线的东东,但是USB的传输距离有很短.咋办呢?? 见下图 http://rextron-cn.com/product_show.asp?id=74

  9. Q_OBJECT宏的作用

    The Q_OBJECT macro at the beginning of the class definition is necessary for all classes that define ...

  10. ListView的ScrollBar设置

    默认ListView的滑动时,右侧会有滑动条显示,等ListView滑动结束时,滑动条消失.修改ScrollBar的显示可以在XML以及CODE中实现. CODE中实现:1.setFastScroll ...