Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Increament

Re: Increament

From: Oliver Wong <oliverwong_at_aforce.com>
Date: Mon, 29 Oct 2001 16:18:14 +0800
Message-ID: <3BDD10C5.660A8F8D@aforce.com>


What is mean by "Dual"?

Brian Tkatch wrote:

> On Mon, 29 Oct 2001 12:02:22 +0800, Oliver Wong
> <oliverwong_at_aforce.com> wrote:
>
> >How can I create a field that will increament by n?
> >Thank you!
> >
> >
> >
>
> Most probably you want to use a SEQUENCE and a TRIGGER.
>
> Check out the CREATE SEQUENCE command. By default it starts at one and
> increments by one, but you can change both of these.
>
> The CREATE TRIGGER command can create a trigger that will
> automatically put the number in the column.
>
> An example:
>
> CREATE TABLE MyTable (Id NUMBER PRIMARY KEY);
>
> CREATE SEQUENCE MyTableSEQ NOCACHE ORDER;
>
> CREATE OR REPLACE TRIGGER MyTableANR
> BEFORE INSERT ON MyTable
> FOR EACH ROW
> BEGIN
> SELECT MyTableSEQ.NEXTVAL INTO :NEW.Id FROM Dual;
> END MyTableANR;
> /
>
> Brian
Received on Mon Oct 29 2001 - 02:18:14 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US