File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
debbie shifferd
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33700
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Debbie,
Try turning this into a select to better see what is going on.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic