• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Code to trigger nightly batch job works .. but I don't know why it works

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We've got an app that runs on a Weblogic 7 server. We use classes that implement Runnable to create threads when the app is first brought up that stay resident (sleeping) until it is time to wake up.

When they wake up each morning, they execute a method to determine if it is time to run. And this is the method that has an Oracle update sql in it that looks to me like it should never work and yet somehow it does.

if(CoiDbUtil.HasBatchStarted("REUSE_DUMMY")==1){
// the job kicks off

}

public static int HasBatchStarted(String batch_str){

Connection con = null;
Statement stmt = null;
String sql_str = new StringBuffer().
append("update config ").
append("set value = (to_char(sysdate, 'mm/dd/yyyy:hh24:mi:ss')) ").
append("where rowid = (select rowid from config where ").
append("name='").append(batch_str).append("') ").
append("and trunc(sysdate)!=trunc(to_date(value)) ").toString();

try{
con = CoiDbConnection.getConnection();
stmt = con.createStatement();
return stmt.executeUpdate( sql_str.toString() );
}
}

It would seem to me that this method would never return a 1 because the
trunc(sysdate) is always going to equal the trunc(to_date(value)).


Can anyone tell me what I am missing here?
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Debbie,
Try turning this into a select to better see what is going on.

 
reply
    Bookmark Topic Watch Topic
  • New Topic