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 -> Re: how to achieve autoincremented PKs (as datatype SERIAL does)

Re: how to achieve autoincremented PKs (as datatype SERIAL does)

From: Frank Ratzlow <frank_ratzlow_at_hotmail.com>
Date: 28 Feb 2003 07:47:26 -0800
Message-ID: <5ef29569.0302280747.7ec3eed4@posting.google.com>


Hallo folks,

thanx a lot for the answers. I will check the docs for the given hints. Sequences and SPs sound (according to the descriptions) much like things I was locking for.

What I appreciate about Oracle SW is the vivid comunity and the wealth of documentation.

cheers

Frank

frank_ratzlow_at_hotmail.com (Frank Ratzlow) wrote in message news:<5ef29569.0302270357.1adad160_at_posting.google.com>...
> 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
Received on Fri Feb 28 2003 - 09:47:26 CST

Original text of this message

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