5 messages in com.mysql.lists.perlRe: Inserting and retrieving id
FromSent OnAttachments
Jan Eden29 Jun 2004 07:34 
William R. Mussatto29 Jun 2004 09:39 
mayuran29 Jun 2004 09:43 
Jan Eden29 Jun 2004 14:21 
Jochen Wiedmann29 Jun 2004 23:24 
Subject:Re: Inserting and retrieving id
From:Jan Eden (lis@janeden.org)
Date:06/29/2004 02:21:13 PM
List:com.mysql.lists.perl

William R. Mussatto wrote on 29.06.2004:

Jan Eden said:

But how can I get the id (INT PRIMARY KEY AUTO_INCREMENT) immediately after inserting new data? Is there a good way to return such a value upon insertion?

add following line into else clause after do. ($id)=$dbh->selectrow_array("SELECT LAST_INSERT_ID()"); BTW: equivalent construct will work for java.

Thanks, William and Mayuran,

that did the trick. I suspected there is a function for such an obvious
necessity, but I got lost in all the manuals around me.

- Jan