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: How to create unique primary index (autoinc feature)?

Re: How to create unique primary index (autoinc feature)?

From: Sybrand Bakker <postmaster_at_sybrandb.demon.nl>
Date: Sat, 22 Jan 2000 11:21:00 +0100
Message-ID: <948536571.3085.0.pluto.d4ee154e@news.demon.nl>


Will this help?
Your reply doesn't explain the sequence concept, Your code is missing a grant and a synonym, your code doesn't make provisions in case someone filled the deptno column (which is very unlikely, but IMO you need to protect the trigger against it)

Basically, you only reply to promote your own software and to attract people to your site, and you do so several times a week.

This begins to become more than annoying, sorry to say so.

Regards,

--
Sybrand Bakker, Oracle DBA

M. Armaghan Saqib <armaghan_at_yahoo.com> wrote in message news:86btnj$inp$1_at_nnrp1.deja.com...
> Oracle does not support any auto-increment column.
>
> You can use my SQL PlusPlus (freeware) to generate the following
> code to implement auto-in column in the database.
>
> Here is an example:
>
> SQL> EXEC S2.bldseq('seq_deptno','ORACLE','dept','deptno')
>
> | DROP SEQUENCE seq_deptno;
> | CREATE SEQUENCE seq_deptno
> | START WITH 1 INCREMENT BY 1
> | MINVALUE 1 MAXVALUE 999999999999999999999999999
> | CYCLE CACHE 20 ORDER;
> |
> | -- This optional trigger applies sequence values to a table column
> thus
> | -- creating an auto-increment column which can be used as primary-key
> |
> | CREATE OR REPLACE TRIGGER trg1_dept
> | BEFORE INSERT
> | ON dept
> | FOR EACH ROW
> | BEGIN
> | SELECT seq_deptno.NEXTVAL
> | INTO :NEW.deptno
> | FROM DUAL;
> | END;
> | /
>
> regards,
> M. Armaghan Saqib
> +---------------------------------------------------------------
> | 1. SQL PlusPlus => Add power to SQL Plus command line
> | 2. SQL Link for XL => Integrate Oracle with XL
> | 3. Oracle CBT with sample GL Accounting System
> | Download free: http://www.geocities.com/armaghan/
> +---------------------------------------------------------------
>
> In article <86bq2k$1iog$1_at_dolf.netfront.net>,
> "Torsetn Trzeciak" <torsten.trzeciak_at_gmx.de> wrote:
> > Hello,
> > I use JDBC with Oracle in a multi user environment.
> > How can I create a unique primary key for inserts.
> > Is there an autoincrement feature available?
> >
> > Thanks in advance
> > Torsten
> >
> > ------
> > Posted via news://freenews.netfront.net
> > Complaints to news_at_netfront.net
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Sat Jan 22 2000 - 04:21:00 CST

Original text of this message

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