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 -> "autonumber" field - how to?

"autonumber" field - how to?

From: Bill Cohagan <bill_at_XNOSPAMXteraquest.com>
Date: Mon, 22 Nov 1999 10:38:40 -0600
Message-ID: <gre_3.60$Ld.14463@newsin1.ispchannel.com>


I'm an Oracle newbie, having worked previously in Access and SQL7. In both of these systems I am able to easily create an "autonumber" field; i.e., a field that is automatically assigned sequential integers as new records are created. I'm having difficulty figuring out how to do this in Oracle 8. (I'm actually using Personal Edition O8).

I've discovered the Sequence object and that is clearly the mechanism to be used. I've also discovered that you cannot reference this object (or its NEXTVAL pseudocolumn) in the DEFAULT spec for a column. I've also attempted writing an INSERT trigger, but can't get it to compile. The statement:

:new."ID Field" := table_SEQ.NEXTVAL

causes a "trigger compiled with errors" message. When I then type SHOW ERRORS, I get "No Errors" !!! If I change the line to:

:new."ID Field" := 99

then it compiles fine.

I would appreciate hearing from anyone who can help me solve this problem.

TIA,
 Bill Received on Mon Nov 22 1999 - 10:38:40 CST

Original text of this message

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