Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> Autoincrement functionality
Hi All,
I am porting a schema to Oracle from mysql that uses AUTOINCREMENT to produce the primary key. In order to keep the application code the same I have to get a number from a sequence and insert into the primary key column at the database level. The only way I have figured out is to use a before insert trigger something like: WARNING: THIS IS UNTESTED PSUEDO CODE CREATE TRIGGER AUTOINCREMENT BEFORE INSERT ON TABLE TEST FOR EACH ROW BEGIN :new.PRIMARY_KEY_ROW = TEST_NUM.nextval; END; Has anyone done this? Any other ideas? I am in digest mode so I will not respond until tomorrow.
TIA
Dave
-- Dave Morgan Senior Database Administrator Internet Barter Inc. www.bartertrust.comReceived on Tue Aug 01 2000 - 12:44:43 CDT