wood burning stoves 2.0*
The moose likes Oracle/OAS and the fly likes Code to trigger nightly batch job works .. but I don't know why it works Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "Code to trigger nightly batch job works .. but I don Watch "Code to trigger nightly batch job works .. but I don New topic
Author

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

debbie shifferd
Greenhorn

Joined: Oct 16, 2003
Posts: 11
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29287
    
140

Debbie,
Try turning this into a select to better see what is going on.



[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Code to trigger nightly batch job works .. but I don't know why it works
 
Similar Threads
Illegal operation exception while trying rollback..
Struts config error , controller not redirecting to required screen.
JSTL jstl.sql.Result
Total Time duration
How to update clob field in oracle