呵呵,这个我做过,Oracle里用“序号生成器+触发器来实现”
刚好有当时的笔记代码,发给你吧
1、序号生成器
create Sequence SeqBbs increment by 1
start with 1
//SeqBbs为序号生成器名
2、查询Seq
select seqbbs.nextVAL from t_users
//t_users为表名
3、触发器
create or replace trigger TR_UserId
before insert on T_Users
for each row
declare
Uid number;
begin
select SeqBBS.nextval into Uid from dual;
:New.F_Id := Uid;
//注意这里F_ID为T_Users主键
end TR_UserId;
先执行1,再执行3
就可以了