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?