Re: Sequences

From: John Nunns <jn14624_at_erols.com>
Date: 17 Sep 1999 12:40:47 GMT
Message-ID: <01bf0123$c14e98e0$4ec77ad1_at_johnboy>


Hi Ken,
To automatically insert the sequence every time you enter a new record you can create a triger like:

create or replace trigger before_insert_tablename_row before insert
on table_name
for each row
begin
select sequence_name.nextval into :new.column_name from dual:

end;

note: dual is, as you know a dummy table.

To test the sequence you can do the following:

First -- create an empty table form your original one as follows: create table copy_table_name as
selecte * from table_name
where 1 = 2;

Second - create a procedure to test the sequence (please note that this insert is not
using the key word VALUES, as it works...) create or replace procedure procedure_name is begin
insert into copy_table_name
select * from table_name;
end;

Third - Test the your sequence type:
execute procedure_name;

This will populate copy_table_name with the records, and the new sequence, from your table_name.

Hope this helps ;)
John Nunez

Ken Halsted <kenman_at_mail.snider.net> wrote in article <ru2b1d27hk989_at_corp.supernews.com>...
> I just created a sequence. How do I assign the sequence to a column on
the
> table I want to use?
>
> Ken.
>
> --
> _________________
> Kenneth W. Halsted
> Mountaire Corporation
> ph: (501) 399-8812
> url: http://www.mountaire.com
> email: kenman_at_mail.snider.net
>
>
>
>
Received on Fri Sep 17 1999 - 14:40:47 CEST

Original text of this message