分成两句 序列不能直接这样使用
declare
v_seq number;
begin
select T_GID_SEQ.nextval into v_seq from dual;
insert into user values (v_seq,'test');
end;

解决方案 »

  1.   

    在同一个会话中,可以使用如下两句:
    insert into USER values (T_GID_SEQ.nextval,'test');
    SELECT T_GID_SEQ.currval FROM DUAL;
    这样是可以得到当前的序列值的。
      

  2.   

    pl/sql中可以这样
    declare
    v_col user.col1%type;
    begin
    ...
    insert into USER(col1,col2) values (T_GID_SEQ.nextval,'test') return col1 into :v_col1;
    ...
      

  3.   

    我是用jdbc 啊,该怎么办呢?
      

  4.   

    用jdbc?应该把T_GID_SEQ.currval 作为output参数传回吧!
      

  5.   

    也可用触发器
    create trigger tri_name
    before insert on USER
    for each row
    begin
    select :new.col_name into 全局变量 from dual;
    end;
    /全局变量可用包作传递