在存储过程中执行3种oracle循环语句
来源:互联网 发布:vb读取硬盘序列号 编辑:程序博客网 时间:2024/06/05 04:47
create or replace procedure proc_msw_strsql
/*
名称:在存储过程中执行3种循环语句
功能:利用循环给表中插入数据
调用:
begin
-- Call the procedure
proc_msw_strsql;
end;
创建人:马素文
创建时间:2010-8-30
*/
is
i int;
begin
i :=1;
loop
insert into proc_msw_strsql(rpt_date ,dept_id,item,qty) values(to_date('2007-01-01','yyyy-MM-dd'),'D'||i,'I'||i,round(i*100/3,3));
exit when i =10;
i :=i+1;
end loop;
--
i :=1;
while i<=5 loop
insert into proc_msw_strsql(rpt_date ,dept_id,item,qty) values(to_date('2007-01-02','yyyy-MM-dd'),'D'||i,'I'||i,round(i*200/3,3));
i :=i+1;
end loop;
--如果指定了reverse选项,则循环控制变量会自动减1,否则自动加1
for j in reverse 1..10 loop
--insert into proc_msw_strsql(rpt_date ,dept_id,item,qty) values(to_date('2007-01-03','yyyy-MM-dd'),'D'||j,'I'||j,round(j*300/3,3));
insert all --first,不会被重复插入
when i <> 2 then into proc_msw_strsql(rpt_date ,dept_id,item,qty)
else into proc_msw_strsql(rpt_date ,dept_id,item,qty)--如果两个表结构完全一样,则列举不用列名
select to_date('2007-01-02','yyyy-MM-dd')as rpt_date,'D'||j as dept_id,'I'||j as item,round(j*300/3,3) as qty from dual;
end loop;
commit;
<<outer_zzl>>--??????
for x in 1..10 loop
<<inner_zzl>>
for y in 1..100 loop
i :=x*y;
exit outer_zzl when i=500;
exit when i =300;
end loop inner_zzl;
--<<inner_zzl>>
end loop outer_zzl;
--<<outer_zzl>>
end;
- 在存储过程中执行3种oracle循环语句
- 在存储过程中执行3种oracle循环语句
- 在存储过程中执行3种oracle循环语句
- 在存储过程中执行oracle循环语句
- oracle 存储过程循环执行update语句
- oracle在存储过程中执行DDL语句
- 在存储过程利用游标循环执行update语句
- 在Oracle中不通过存储过程一次执行多条SQL语句Oracle PL/SQL
- 在Oracle中不通过存储过程一次执行多条SQL语句Oracle PL/SQL
- 在java中执行oracle存储过程
- oracle执行存储过程语句
- oracle 解除 sql语句、存储过程在执行中造成的锁
- oracle 解除 sql语句、存储过程在执行中造成的锁
- oracle存储过程中如何执行动态SQL语句
- oracle存储过程中如何执行动态SQL语句
- 在SQL SERVER 2005存储过程中,使用循环语句
- 在SQL SERVER 2005存储过程中,使用循环语句
- 在nhibernate中执行SQL语句和存储过程
- 启用apache expires_module 模块
- Java中关于类的初始化
- 如何分辨主板的USB3.0接口是不是真的
- C++类中显式定义内联函数
- 从别人那里转的20条格言
- 在存储过程中执行3种oracle循环语句
- 网络神采关键词过滤NET插件
- .infig.status: error: cannot find input file
- Oracle 10G 如何使用超过1.7G的内存
- 黑马程序员-java 交通灯管理系统
- emacs 快捷键(包括C/C++模式)
- oracle 错误列表
- 亦经典语录
- 让你的代码变的更加强大(Making your C++ code robust)