Forums Register Login

getGeneratedKeys() + batchUpdate

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
"Sanchi Sanchi",
Please check your private messages regarding an important administrative matter.
-Ben
+Pie Number of slices to send: Send
Hello All, I would appreciate any views or suggesting on this. Hoping to hear from someone.

Thanks,
Sanchi
+Pie Number of slices to send: Send
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
I think she's lovely. It's this tiny ad that called her crazy:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2839 times.
Similar Threads
Inserting Files to Database.
building a dataTable from java code
Spring Batch for reading file and checking data in database
Batch consisting of multiple PreparedStatements
DAO class design
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:33:20.