- create or replace procedure 存储过程名(
- 参数名 in 参数类型,
- p_name in varchar2,
- p_password in varchar2
- aaout integer --返回的参数
- ) --这里可以有许多参数
- is
- cursor cc is select did from taskdetails; --循环用到的cursor游标
- path varchar2(2000);--定义变量 格式为: 变量名 + 变量类型 +(数值)
- tdpath varchar2(2000);
- type array is table of integer(5) index by binary_integer;--oracle数据库没有数组,所有要自己定义,定义为integer5位,下标为integer
- arr array;--arr的类型为自定义的array类型
- begin
- arr(0):=1;
- arr(1):=22;
- tdpath :='abc';--变量赋值用:=
- for c in cc loop --循环开始
- select t.filepath into path from temptask ;--查询出来的值赋给path 用到into 关键字
EXCEPTION --异常捕获 当出现no_data_found异常时 会被捕获
WHEN NO_DATA_FOUND THEN
path := null;
END; - --还有其他exception需要捕获
- Exception
when others then
rollback;--回滚 - end loop;--循环结束
- for i in 0..3 loop --循环0到3
- null;
- end loop;
- if arr(0)>0 then
- arr(0):=arr(0)-1;
- else
- arr(0):=arr(0)+1;
- end if;
- case i --case的用法
when 0 then
dbms_output.put_line('1');
when 1 then
dbms_output.put_line('2');
when 2 then
dbms_output.put_line('3');
when 3 then
dbms_output.put_line('4');
end case; - end;
oracle存储过程学习笔记
猜你喜欢
转载自wb284551926.iteye.com/blog/1682356
今日推荐
周排行