设为首页 加入收藏

TOP

Oracle有参数带返回值的存储过程简单例子
2014-11-24 02:28:52 来源: 作者: 【 】 浏览:2
Tags:Oracle 参数 返回 存储 过程 简单 例子

create or replace procedure caf_trackdiffbyId(

sendid in number,

userid in varchar ,

diffnum in number,

lats in number,

latn in number,

lngw in number,

lnge in number,

minid out number ,

maxid out number

) is

currDate date;

minDate date;

maxDate date;

subMin number;

Cursor baseMinCursor is select * from caf_usertrack where datetime

Cursor baseMaxCursor is select * from caf_usertrack where datetime>currDate order by id asc ;

begin

select datetime into currDate from caf_usertrack where id=sendid and userid=userid and

lat >= lats and lat <= latn and lng >= lngw and lng <= lnge ;

begin

if currDate is not null then

begin

minDate := currDate;

maxDate := currDate;

end;

end if;

for sysd in baseMinCursor loop --取得最小的ID值 www.2cto.com

begin

subMin := round(to_number(minDate-sysd.datetime)*24*60,2);

if subMin <= diffnum then

begin

minDate := sysd.datetime;

end;

else

begin

minid := sysd.id;

dbms_output.put_line('min'||minid);

exit;

end;

end if;

end;

end loop;

for sysd in baseMaxCursor loop --取得最大的ID值

begin

subMin := round(to_number(sysd.datetime-maxDate)*24*60,2);

if subMin <= diffnum then

begin

maxDate := sysd.datetime;

end;

else

begin

maxid := sysd.id;

dbms_output.put_line('maxid'||maxid);

exit;

end;

end if;

end;

end loop;

end;

end caf_trackdiffbyId;

摘自 yuefengyuan的专栏

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇 Linux 内核参数 和 Oracle相关参.. 下一篇oracle 10g中db_recovery_file_de..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: