• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Exception handling

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

While running batch jobs i am trying to retrieve some data from one table consists of lacks of records and insert into another table like this
st.executeUpdate("INSERT INTO Table2(source_id,period) SELECT Table1 .RESOURCE_ID, Table1 .period FROM Table1");

but the issue is if exception occurs while inserting a record then the whole job is getting stopped.so what's requirement is

if exception occurs for a record then i should skip that record and continue the process with remaining records.

is there any solution ?

Thanks in advance




 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I assume you have many Statement.executeUpdate() for this purpose ,

so run every statement.executeUpdate() with in try and catch blocks .

clarify if you dont understand this .
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think there will be any direct way to solve that issue. Your best bet is to avoid that exception by first cleaning the data or filtering it before inserting.

Since you are inserting lakhs of records, inserting one record at a time will drastically increase the time taken to complete the job. So, that solution might not work for your case.
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are on Oracle 10.2 or higher, you could utilize DML error logging, which seems to suit exactly your case. See

http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/sqlplsql.htm#sthref3393
http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/tables.htm#ADMIN10261

 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic