Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: how to achieve autoincremented PKs (as datatype SERIAL does)
See the Co-operative FAQ listed below.
Search for "increment".
-- Regards Jonathan Lewis http://www.jlcomp.demon.co.uk Coming soon one-day tutorials: Cost Based Optimisation Trouble-shooting and Tuning Indexing Strategies (see http://www.jlcomp.demon.co.uk/tutorial.html ) ____UK_______March 19th ____USA_(FL)_May 2nd Next Seminar dates: (see http://www.jlcomp.demon.co.uk/seminar.html ) ____USA_(CA, TX)_August The Co-operative Oracle Users' FAQ http://www.jlcomp.demon.co.uk/faq/ind_faq.html "Frank Ratzlow" <frank_ratzlow_at_hotmail.com> wrote in message news:5ef29569.0302270357.1adad160_at_posting.google.com...Received on Thu Feb 27 2003 - 06:19:36 CST
> Hallo folks,
>
> is it possible to put the handling of autogenerating PK to Oracle? I
> think to remember from Informix the datatype SERIAL that makes it
> quite easy as I don't have to determine a new value for the key.
> I just would like to insert a row without having to know or
> (calculate) the value of the new record.
> For a short time I thought of:
>
> ============
> INSERT INTO customer (customerid, firstname, lastname) VALUES
((SELECT
> MAX(customerid) FROM customer) + 1, 'Sven', 'Grundmann');
> ============
>
> but this cannot be a serious solution since it would run into
trouble
> with concurrent inserts.
> Could anyone give me a hint how to implement something I only have
to
> do something like
>
> INSERT INTO customer VALUES ('Sven','Grundmann');
>
> Finally, to top all this I want to execute this statment from within
> Java Code via JDBC. Is there any supported way to precalc the pk?
>
>
> TIA
>
> Frank
> frank_ratzlow_at_nojunk.hotmail.com