Oracle 存储过程中的循环,条件判断,存储过程,游标小结
2013-02-19 16:36
399 查看
Oracle 存储过程中的循环,条件判断
for...in...loop
end loop;循环
for x in 1..100 loop
deal with
end loop;
loop循环
loop
执行语句
exit when 条件
end loop
while循环
i:=1;
while i<99
Loop
begin
i:=i+1;
end;
end loop;
条件判断
1.if...elsif...else...end if
if conditions
then
consitions result;
elsif xxx and xxx
then
conditions result;
else
conditions result;
end if
2.case when end case判断
v_num:=1
case v_num
when 1 then
conditions reuslt;
when 2 then
conditions result;
else
null;
end case;
游标cursor
create or replace procedure pro_1(
checknum in number,
ref_cursor out sys_refcursor
)
as
begin
open ref_cursor for select × from.......
end pro_1;
sys_refcursor 的三个状态属性
%notfound
%found
%roucount 当前游标所指向的行位置
example1:通过游标返回一个结果集并将这个游标遍历输出
create or replace procedure pro_1(
checknum in number,
ref_cursor out sys_refcursor
)
as
begin
open ref_cursor for select × from.......;
loop
fetch ref_cursor into t_tmp;
exit when ref_cursor%notfound;
dbms_output.put_line(t_tmp.id);
update table....
where id=t_tmp.id;
commit;
end loop;
close ref_cursor;
end pro_1;
for...in...loop
end loop;循环
for x in 1..100 loop
deal with
end loop;
loop循环
loop
执行语句
exit when 条件
end loop
while循环
i:=1;
while i<99
Loop
begin
i:=i+1;
end;
end loop;
条件判断
1.if...elsif...else...end if
if conditions
then
consitions result;
elsif xxx and xxx
then
conditions result;
else
conditions result;
end if
2.case when end case判断
v_num:=1
case v_num
when 1 then
conditions reuslt;
when 2 then
conditions result;
else
null;
end case;
游标cursor
create or replace procedure pro_1(
checknum in number,
ref_cursor out sys_refcursor
)
as
begin
open ref_cursor for select × from.......
end pro_1;
sys_refcursor 的三个状态属性
%notfound
%found
%roucount 当前游标所指向的行位置
example1:通过游标返回一个结果集并将这个游标遍历输出
create or replace procedure pro_1(
checknum in number,
ref_cursor out sys_refcursor
)
as
begin
open ref_cursor for select × from.......;
loop
fetch ref_cursor into t_tmp;
exit when ref_cursor%notfound;
dbms_output.put_line(t_tmp.id);
update table....
where id=t_tmp.id;
commit;
end loop;
close ref_cursor;
end pro_1;
相关文章推荐
- 数据库技术_Orcale技术(0002)_5分钟会用存储过程_存储过程简单实例(包含循环、条件、增改查、参数传入、变量赋值、java调用等)
- oracle 采用游标循环插入数据的存储过程
- MySql存储过程—逻辑判断,条件控制,循环控制
- mysql存储过程查询结果循环遍历 判断 赋值 游标等基本操作
- oracle中创建存储过程,以及存储过程中调用游标
- oracle存储过程中 使用游标做循环封装数据集
- Day60-Oracle04 - PLSQL编程、游标cursor、例外exception、存储过程(procedure)、存储函数(function)、java调用存储过程、触发器(trigger)
- oracle 存储过程循环插入10000条记录---存储过程
- MySql存储过程—逻辑判断,条件控制,循环控制
- mysql 存储过程示例,有参有返回值,使用到了判断,循环,游标,临时表,事务
- oracle在存储过程里面调用其它的存储过程(包含游标)
- oracle开发中的存储过程,游标,if判断经典例子
- 游标、例外、存储过程、存储函数、java调用存储过程、触发器(Oracle之二)
- oracle存储过程如何定义,动态判断条件sql如何书写
- 13.0 Mybatis_扩展_存储过程_oracle中创建一个带游标的存储过程
- 游标、例外、存储过程、存储函数、java调用存储过程、触发器(Oracle之二)
- mysql存储过程查询结果循环遍历 判断 赋值 游标等基本操作
- mysql存储过程查询结果循环遍历 判断 赋值 游标等基本操作
- oracle开发中的存储过程,游标,if判断经典例子
- Java调用oracle存储过程通过游标返回临时表数据