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

Home -> Community -> Usenet -> c.d.o.server -> Re: A proper FAQ - Wish fulfillment

Re: A proper FAQ - Wish fulfillment

From: Niall Litchfield <n-litchfield_at_audit-commission.gov.uk>
Date: Mon, 10 Mar 2003 14:29:50 -0000
Message-ID: <3e6ca15e$0$227$ed9e5944@reading.news.pipex.net>


"Pablo Sanchez" <pablo_at_dev.null> wrote in message news:Xns933A463B9B830pingottpingottbah_at_216.166.71.233...
> "Niall Litchfield" <n-litchfield_at_audit-commission.gov.uk> wrote in
> news:3e6c9546$0$225$ed9e5944_at_reading.news.pipex.net:
>
> > b) There is no autoincrementing datatype in Oracle. You need to create a
> > sequence and a before insert row level trigger. For example
> >
> > create table t(id number,description varchar2(50));
> >
> > create sequence seq_t start with 1 increment by 1 cache 50;
> >
> > create trigger trg_i_t
> > before insert on t
> > for each row
> > begin
> > select seq_t.nextval into :new.id from dual;
> > end;
> > /
>
> - or -
>
> -- without using a trigger:
>
> INSERT INTO t SELECT seq_t.nextval, 'hola!' FROM DUAL;

Good point, and there is of course yet another version (which saves an infinitesimal amount of time)

insert into t values(seq_t.nextval,'hola');

--
Niall Litchfield
Oracle DBA
Audit Commission UK
Received on Mon Mar 10 2003 - 08:29:50 CST

Original text of this message

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