欢迎投稿

今日深度:

Oracle中序列(SEQUENCE)的使用一例

Oracle中序列(SEQUENCE)的使用一例


Oracle中序列(SEQUENCE)的使用一例
 
曾经在触发器中使用序列(SEQUENCE):
 
create or replace trigger TRI_SUPPLIER
  before insert on   SUPPLIER
  for each row
begin
  select seq_supid.NEXTVAL into:new.supcode from dual;
  select seq_supid.CURRVAL into:new.supID from dual;
end;

 

 
显然,忽略了并发,修改后如下:
 
create or replace trigger TRI_SUPPLIER
  before insert on   SUPPLIER
  for each row
declare  v_supval number(20);
begin
  select  seq_supid.NEXTVAL into v_supval  from dual;
  select v_supval  into:new.supcode from dual;
  select v_supval  into:new.supID from dual;
end;

 

 

www.htsjk.Com true http://www.htsjk.com/oracle/21566.html NewsArticle Oracle中序列(SEQUENCE)的使用一例 Oracle中序列(SEQUENCE)的使用一例 曾经在触发器中使用序列(SEQUENCE): create or replace trigger TRI_SUPPLIER before insert on SUPPLIER for each rowbegin select seq_supid...
相关文章
    暂无相关文章
评论暂时关闭