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

Reply via email to