db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Masoud Kalali <kal...@gmail.com>
Subject Re: How to find master record primary key to use it in inserting details records
Date Wed, 12 Apr 2006 20:03:27 GMT
Legolas Woodland wrote:
> Hi
> Thank you for reading my post
> I have two tables which are related to eachother using a column (master 
> details)
> my problem is that master table primary key is auto increment
> so when i insert a recoed to it i can not determine the primary key value
> so i do not know the key ,
> Now my problem is that how i can find the primary key of master record 
> to use it when i inert
> details records ?
> I should say that it is a very high hit application , before i post this 
> message i though that i can execute a query and select latest inserted 
> record
> but latest inserted record could be from another user not the current user.
> Thanks
you may use IDENTITY_VAL_LOCAL()  , which return latest identity value 
inserted for a table by the connection that call this function.
so you will have no problem about multiple connections because  each 
connection will have its own state

Regards , Masoud Kalali

View raw message