日期:2014-05-17 浏览次数:20880 次
create or replace function xproxy_id_server_next(key in varchar2) return number is
ret_val xproxy_id_server_next.curid%type;
cur number;
success number;
begin
cur:=0;
success:=0;
WHILE(success <= 0)
LOOP
begin
select curid into cur from xproxy_id_server_next where idxname = key for update;
update xproxy_id_server set curid=cur+500 where idxname=key and curid=cur;
success:=1;
exception
when no_data_found then
begin
insert into xproxy_id_server_next (idxname,curid) values(key,1);
exception when DUP_VAL_ON_INDEX then
continue;
end;
end;
END LOOP;
ret_val:=cur;
return ret_val;
end;
/