db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stanley Bradbury <Stan.Bradb...@gmail.com>
Subject Re: Auto increment fields , evil or good ? I need advice on a design
Date Tue, 22 Nov 2005 22:19:47 GMT
Legolas Woodland wrote:

> Hi
> Thank you for reading my post.
> here is my question :
> using auto increment fields are good or bad ?
> what is best practice for them : When to use them  , how to use them , 
> when to avoide them?
>
> consider the following condition :
> I have one table which is related to another table in a one-to-one 
> relation.
> parent table primary  key is auto increment (what should i use if auto 
> increment is evil?)
> now i insert a record into parent Table , i should include parent 
> table Primary key into child table
> to relate it with parent table.
> after i insert parent record i should execute a select statement to 
> find the inserted record Primary key and include it into child table 
> record
> My question is :
> how i can avoide this select statement execution ?
> what should i use instead of That auto increment field ?
>
>
> Thank you so much.
>
 From JDBC you can use java.sql.Statement.getGeneratedKeys().  See this 
link for an example:
http://publib.boulder.ibm.com/infocenter/cscv/v10r1/topic/com.ibm.cloudscape.doc/crefjavstateautogen.html

A description of IDENTITY_VAL_LOCAL function can be found at:
http://publib.boulder.ibm.com/infocenter/cscv/v10r1/topic/com.ibm.cloudscape.doc/rrefidentityvallocal.html#rrefidentityvallocal


Mime
View raw message