Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is there a way of knowing which record failed in Batch Insert

 
Gaurav Chikara
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All

Inside a loop I am setting the input parameters of prepared statement to be inserted ane suppose it fails due to a rason that input value is too large for a colmn for some record in an iteration i.
Since i already has reached the threshold value when I am executing a batch so I seem to have lost which culprit record at which iteration caused it
PreparedStatement doesn't seem to have any clue on finding this
Does any one of you have faced similar situation and know of any crack ?

Thanks in advance
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might help if you can give code snippet. It's not clear what you were doing with the description. Anyway
- Is the loop used to construct the statement and added to a batch to be executed through executeBatch()? If not what do you meant by crossed the threshold?
 
Chad Clites
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sort of confused... a crack for what? A crack is a program or process that makes crippled software into fully functioning software, so I don't see how that pertains to your situation.(At least that's what I always thought it meant).

You could do several different things. One, you could check the data for size before it gets inserted into the prepared statement. Or you could dump your data into a comma delimited file and insert the data from the sql command line.
 
Gaurav Chikara
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using executeBatch and by threshold I meant the size of collection (which I am passing ott his function)
I get the input paremeters from the dataObject of this collection and set them as setters of preparedstatement which I have created before loop

Code snippet is very huge but this is what I am doing (In a nutshell)
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the executeBatch() api description, the return type is int array with the status code of the each statement executed (the order in which it's added to the batch). It should be fairly easy to identify the statement that failed (unless the driver you use doesn't support this feature).

Take a look at the executeBatch() api description let us know if it doesn't work.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic