Announcement

Collapse
No announcement yet.

Executing SQL Statement into script tab

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Executing SQL Statement into script tab

    Sorry Guys!!! It's Fixed!!! The code works!!!

    But I got a new issue, how can I execute the code in the script tab just once ?
    The code has been executed how many times I got in my result set from the source.

    Thanks

    *********************************************

    Hi everyone!

    I was trying to execute a routine to make an insert after finish my process.

    Is that possible ?

    The code is below:

    ************************************************** **********************
    // This script executes once after a message has been processed
    var dbConn = DatabaseConnectionFactory.createDatabaseConnection ('net.sourceforge.jtds.jdbc.Driver','jdbc:jtds:sql server://address:1433/database','sa','password');

    var params = new Packages.java.util.ArrayList();
    params.add(globalMap.get('Phcbacquireddataid'));

    var expression = "INSERT IGNORE INTO AcquiredDataSent (AdsAcqID, AdsDateSent) VALUES (?, GETDATE())";
    var result = dbConn.executeUpdate(expression, params);
    logger.info(expression);
    logger.error('message: ' + result);
    dbConn.close();
    return;
    ************************************************** **********************

    the script is configured as postprocessor.

    Follow below the error message

    ************************************************** **********************
    ERROR-406: JDBC Connector error
    ERROR MESSAGE: Error writing to database:
    org.mozilla.javascript.WrappedException: Wrapped java.sql.SQLException: Could not find stored procedure 'expression'. (af218145-21ac-46e2-a5cd-c6fa56feaeaf#3)
    at org.mozilla.javascript.Context.throwAsScriptRuntim eEx(Context.java:1693)
    at org.mozilla.javascript.MemberBox.invoke(MemberBox. java:157)
    at org.mozilla.javascript.NativeJavaMethod.call(Nativ eJavaMethod.java:201)
    at org.mozilla.javascript.optimizer.OptRuntime.call1( OptRuntime.java:64)
    at org.mozilla.javascript.gen.c23._c6(af218145-21ac-46e2-a5cd-c6fa56feaeaf:3)
    at org.mozilla.javascript.gen.c23.call(af218145-21ac-46e2-a5cd-c6fa56feaeaf)
    at org.mozilla.javascript.optimizer.OptRuntime.callNa me0(OptRuntime.java:106)
    at org.mozilla.javascript.gen.c23._c0(af218145-21ac-46e2-a5cd-c6fa56feaeaf:8)
    at org.mozilla.javascript.gen.c23.call(af218145-21ac-46e2-a5cd-c6fa56feaeaf)
    at org.mozilla.javascript.ContextFactory.doTopCall(Co ntextFactory.java:337)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(Scr iptRuntime.java:2755)
    at org.mozilla.javascript.gen.c23.call(af218145-21ac-46e2-a5cd-c6fa56feaeaf)
    at org.mozilla.javascript.gen.c23.exec(af218145-21ac-46e2-a5cd-c6fa56feaeaf)
    ************************************************** **********************

    seems that my implementation wasn't recognized.

    Does someone already did that before ?

    Thanks a lot. :whistle:

    Post edited by: Alexander, at: 11/19/2007 21:40

    Post edited by: Alexander, at: 11/19/2007 22:44

    Post edited by: Alexander, at: 11/19/2007 22:45
Working...
X