利用oracle的存储过程和sys_sequence表替代sequence的功能

来源:互联网 发布:微商做图换头像软件 编辑:程序博客网 时间:2024/05/12 23:48

利用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;/

该代码摘自搜索引擎

原创粉丝点击