利用oracle的存储过程和sys_sequence表替代sequence的功能
该功能能够适用于并发应用下的需求
代码:
create or replace procedure get_sequence(key in varchar2) return number
ret_val sys_sequence.lastid%type;
begin
update sys_sequence
set lastid = lastid + 1
where code = key;
if sql%notfound then
insert into sys_sequence(code, lastid)
values (key, 1);
end if;
select lastid
into ret_val
where code = key;
return ret_val;
end;
/
该代码摘自搜索引擎