Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Autoincrement functionality

Autoincrement functionality

From: Dave Morgan <dmorgan_at_bartertrust.com>
Date: Tue, 01 Aug 2000 10:44:43 -0700
Message-Id: <10576.113506@fatcity.com>


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.com
Received on Tue Aug 01 2000 - 12:44:43 CDT

Original text of this message

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