Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getGeneratedKeys() + batchUpdate

 
C.P Sanchalanam
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there,

Is it allowed to use getGeneratedKeys() on PreparedStatement to get all the generated unique IDs (seq.nextval) generated in a batch update? please advice.

If it is not allowed please could you suggest a method to retrieve sequence Ids from a batch update.

Here is the requirement:

I have 2 tables DataTable1 (columns: ID, Name) and DataTable2 (REF-ID, value) and the relationship between these table is one-to-many:

I am using an batch insert into DataTable1 to add multiple rows and each row's ID is unique and it is generated by seq.nextval. Now, after this batch insert I need to retrieve all the generated IDs and use these IDs to inser data into the second table(DataTable2).


Thanks for your help.

Sanchi
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Sanchi Sanchi",
Please check your private messages regarding an important administrative matter.
-Ben
 
C.P Sanchalanam
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All, I would appreciate any views or suggesting on this. Hoping to hear from someone.

Thanks,
Sanchi
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would need to try it. My guess is that it would be vendor specific and would either return the generated keys, or would throw an Exception when called from the PreparedStatement
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic