first of all, let me say that I'm a total JAVA newbie. But I have this problem. I need to insert data in to a set of parent child tables. The data structure looks this
data item 1 - (level 1 data)
data item 1.1 - (level 2 data) data item 1.2 data item 2 data item 2.1 data item 2.2 data item 2.2.1 - (level 3 data) data item 2.2.2 data item 3...There are 3 tables in Oracle.
Level1_Data_Table(Level_1_ID, name, etc...) Level2_Data_Table(Level_2_ID, Level_1_ID, name, etc...) Level3_Data_Table(Level_3_ID, Level_1_ID, name, etc...)There could be thousands or Level 1, Level 2, and Level 3 data.
The IDs are from level1Seq.nextVal, level2Seq.nextVal, level3Seq.nextVal.
How can I do a batch inser开发者_如何学Got a batch insert for level 1 data, get all the IDs and use it to do a batch insert of level 2, and do the same for level 3?
Currently I'm using Spring's jdbcTemplate.batchUpdate to do the inserts. But it's super slow. Any help would be appreciated.
Thanks in advance!
PL/SQL has a RETURNING construct that can return all ID values as an array. There is Oracle documentation that describes how you pass arrays. I did it once with Spring.
精彩评论