Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Advice please - Sequences, how do you use them?
Carl Sarelius wrote:
>
> Hi,
>
> I'm new to Pers Oracle 8 (and Oracle in general) and I'm after some
> advice.
>
> For an assignment I have created a number of tables and put them in a
> project. Each of these tables has a primary key identified. To ease
> data input (at this stage through Navigator) I found a reference to
> the "sequence" statement and created a sequence with the aim of
> automatically creating the next number when inputting data.
>
> My question is - how do I use it? My manual is not so clear on the
> method of execution. Also does the primary key attribute that the
> sequence will update need to be of a specific data type?
>
> Advice appreciated.
>
> --
> Carl Sarelius
> Carl.Sarelius_at_bigpond.com
> Melbourne, Australia
hi carl,
you use sequences in this case inside a trigger accosiated with the table, e.g.
create sequence seq_problem_report
start with 1000
increment by 1;
create or replace trigger tr_problem_report
before insert on problem_report for each row
declare id number;
begin
select seq_problem_report.nextval into id from dual; :new.id := id;
hope this helps...
--
cu maxx
to reply just remove the no-spam. from my address Received on Wed Aug 05 1998 - 06:54:18 CDT
![]() |
![]() |