| Author |
problem with bulk update and auto_increment
|
Ravinder Rana
Greenhorn
Joined: Dec 07, 2006
Posts: 19
|
|
Hi All, I need some help from you guys regarding bulk update. The scenario is as follows: I have 3 tables in my DB: Person, Person_Phone_Numbers and Person_custom_info Person table has a id(AUTO_INCREMENT)and Person_Phone_Numbers and Person_custom_info tables has this as their foreign key. The no. of records which I have to insert at a time will be somewhere between 50 to 200, so I want to do a batch insert i.e. first insert all Person info followed by Person_Phone_Numbers and Person_custom_info. Now the problem is, to insert data in Person_Phone_Numbers and Person_custom_info tables I need the Person ID value's. Is there a way to get these values? I am using MySQL as database. All inputs appreciated. Thanks
|
 |
Jan Cumps
Bartender
Joined: Dec 20, 2006
Posts: 2350
|
|
You can use java.sql.Statement.getGeneratedKeys(). It's documented in the MySQL 5.0 Reference Manual, 23.4.5.1. Basic JDBC Concepts: 23.4.5.1.4. Retrieving AUTO_INCREMENT Column Values. Regards, Jan
|
OCUP UML fundamental
ITIL foundation
|
 |
 |
|
|
subject: problem with bulk update and auto_increment
|
|
|