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: Identity column?

Re: Identity column?

From: Dave Waterworth <pscdaw_at_ihug.com.au>
Date: Sat, 23 Oct 1999 10:29:10 +1000
Message-ID: <7uqvlc$d42$1@toto.tig.com.au>


There isn't such a type in Oracle (at least V7), you have to create a sequence, the create a before insert trigger which grabs the next value from the sequence and sets the identity field to that value.

i.e.

table is t_mytable with a column called identity, sequence named s_mysequence

CREATE OR REPLACE TRIGGER bi_mytable BEFORE INSERT ON t_mytable AS

    DECLARE
        v_identity INTEGER;
    BEGIN

        SELECT s_mysequecne.NEXTVAL INTO v_identity FROM DUAL;
        :new.identity := v_identity;

    END;
END; Syntax is probably incorrect, but it's the principle that counts

Cheers

Dave Waterworth

Bill Weaks <bill_at_indmolding.nospam.com> wrote in message news:3810DBA0.66C5AFCF_at_indmolding.nospam.com...
> Sounds silly, I suppose, but I can't find documentation on how to create
> an IDENTITY column in Oracle 7!
>
> I see ROWID, but that doesn't cut it.
>
> My experience thus far has been with MS SQL 6.5+, and they have a way to
> create an autoincrementing field in a table.
>
> Could somebody shed some light, please?
>
> Thanks
>
Received on Fri Oct 22 1999 - 19:29:10 CDT

Original text of this message

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