On Tue, Jan 20, 2004 at 12:35:07PM +0100, Marco Paci wrote: > Environment OS:windows 2003 server, PLATFORM:.NET framework 1.1, > LANGUAGE:C#, .NET PROVIDER:MySQLDriverCS > > In an application I'm developing on top of mysql, I wanna use as primary > key for tables an autoincrement field. > Every time I insert a new record I need to read the value assigned to > the PK field for that record. > Since the process of inserting a new record and reading its PK field > value is a two step process implemented by: > 1) insert into tablename (columnnames) values(....) > 2) select last_insert_id() > ,and since because of the architecture of my application I cannot > prevent that 2 concurrent insertions won't be done and since I wanna use > a read_commited isolation level for the transaction, I'm wondering if is > there any way to determine securely the value of an insertion. > > I mean. > I've 2 thread th1 and th2. > > > | Insert a new record > | Insert a new Record > > | Read the value of PK field > | Read the value of PK field > | > | > | > | > v > Time Thread 1 Thread 2 > Axis > > > Is the value read by the thread 1 for the PK field correct?
Read http://www.mysql.com/doc/en/Getting_unique_ID.html. It's kept on a per-connection basis. Balazs -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]