You have to add a trigger and a sequence to do it.  This is the default
format for a trigger to do autonumbering - it sets the identity field
(myField) if the record is new, and raises an exception if someone tries to
change it.

declare
        iCounter                mySchema.myTable.myField%Type;
        e                       exception;

begin
        if inserting then
                select seq_autonumber.nextval into iCounter from dual;

                :new.myField := iCounter;
        end if;

        if updating then
                if not (:new.myField = :old.myField) then
                        raise e;
                end if;
        end if;

exception
        when e then
                raise_application_error(-20000,'Cannot Change Counter
Value');
end;


Dan

-----Original Message-----
From: Duane Boudreau [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 27, 2000 8:22 AM
To: [EMAIL PROTECTED]
Subject: RE: oracle question


Mario,

Do you happen to know the syntax for adding an identity field to an oracle
table?

Cheers,
Duane


------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to