The Oracle sequence (SEQUENCE) using a case

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Once the use of sequence in the trigger(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;

Obviously, ignore concurrency, modified as follows:

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;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Charlotte at December 16, 2013 - 3:36 PM