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

Home -> Community -> Usenet -> c.d.o.server -> [Newbie] Serial Keys - How to implement

[Newbie] Serial Keys - How to implement

From: David C. Harrison <dch_at_dchsoftware.co.uk>
Date: 23 Jun 1998 07:07:23 GMT
Message-ID: <01bd9e76$6edc41e0$2022fe90@SacDevMaster1.cisco.com>

I guess this is probably a RTFM, but the product has yet to be delivered, so
I haven't got a manual yet, bummer.

Anyhoo...

How would I go about implementing an equivelant to the Informix serial data type
in an Oracle database?

If I have a table like this:

	CREATE TABLE customer
	(
		customer	INTEGER NOT NULL,
		name		CHAR(32) NOT NULL,
		PRIMARY KEY (customer)
	);

How do I make a statement like this:

	INSERT INTO customer
	VALUES (0, 'Baney Rubble');

auto increment the value of the primary key?

I guess I'm going to need a trigger/procedure pair, but do I need to create a
table that stores the last used key? (give it row level locking, select and update
in one transaction?) or do I just do a select MAX(customer) in the proc?

Any and all advice much appreciated.

Free T-Shirt for the best answer! (no kidding)

Thanks!



David C. Harrison
DCH Software Limited
Tel: +44 (0)1276 450031
Fax: +44 (0)1276 450039 Received on Tue Jun 23 1998 - 02:07:23 CDT

Original text of this message

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