您的位置:首页 > 数据库

pl/sql 存储过程实例

2012-05-06 00:51 337 查看
create or replace function IsDone(s_id in varchar2,s_TaskNum in varchar2,s_TaskType in integer)
return integer is
/*
功能描述:此存储过程用来验证任务是否完成,有无异常
传入参数3个,分别不同类型,返回值integer类型
返回值:0 正常、1 执行sql错误 、-1存储过程调用有误
*/
//定义变量
type   stringArr   is   varray(2)   of   varchar2(30); //定义一个定长的字符串数组数据类型
dflag          integer;//返回值
iCount         integer;
strs           stringArr;
s_taskid       varchar2(20);
begin
begin
iCount := splitstr(s_TaskNum, '_', strs);//自定义函数,截取字符串
s_taskid:=strs(1);

select  flag
into dflag
from table_Task t
where taskid = s_taskid
and id=s_id
and taskType = s_TaskType
and rownum=1
order by flag asc;
exception
when others then
return 1;//执行sql语句异常
end;
return dflag;
EXCEPTION
when others then
return - 1;//调用存储过程失败
END IsDone;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: