web stats
Mirth Community - View Single Post - Oracle stored procedure call does not work
View Single Post
  #8  
Old 09-07-2018, 09:44 AM
nicovn nicovn is offline
OBX.2 Kenobi
 
Join Date: Oct 2006
Location: Belgium
Posts: 64
nicovn
Default

This should do the trick ...

// database reader javascript source code starts here
var dbConn;

try {
dbConn = DatabaseConnectionFactory.createDatabaseConnection ('oracle.jdbc.driver.OracleDriver',
'jdbcracle:thin:@oracleserver:1521:XE', 'amaron', 'proctest');

var jdbcNativeConn = dbConn.getConnection();

var spstmt = jdbcNativeConn.prepareCall("{ call MIRTH_TEST_PROCEDURE (?) }");
spstmt.registerOutParameter (1, Packages.oracle.jdbc.OracleTypes.CURSOR);

// call the stored procedure
spstmt.execute();

// get the resultset object from the output parameter
var result = spstmt.getObject(1, java.sql.ResultSet);

// copy the resultset into a cachedrowset (required for mirth)
var cachedRowSet = new Packages.com.sun.rowset.CachedRowSetImpl();
cachedRowSet.populate(result);

// close the original resultset
result.close();

logger.debug("hoera! got the records");

return cachedRowSet;

} finally {
if (dbConn) {
dbConn.close();
}
}

// end of code


Best Regards

Nico
__________________
Nico Vannieuwenhuyze

Amaron.be
Reply With Quote