I have a xml file that I am looping on a particular node to extract data. I need to reference that value of the extraction and search a ODBC connection csv file for another value. My connection works and I am able to pull data in but not in the way I am looking for. As soon as I put the ODBC connection and extraction into the repeat steps, everything breaks and I am getting an error “Cannot read property fields from undefined”.
var connectionURL = “jdbc:odbc:TrainingChecklist”;
//var Description = record.tables.EDP[1].fields.Description;
var Description = record.tables.EDP[steps.currentLoopCounter].fields.Description;
if(Description){
var csvConnection = db.connect(connectionURL,“”,“”);
var csvQuery = “SELECT * FROM "psocodes.csv" WHERE Description=” + “'” + Description + “'”;
logger.info(csvQuery);
resultSet = csvConnection.createStatement().executeQuery(csvQuery);
logger.info(resultSet);
resultSet.next();
}
Also, in the following query:
“SELECT * FROM “psocodes.csv” WHERE Description=” + “’” + Description + “’”;
Make sure that the quotes around psocodes.csv aren’t the same as the ones handling the SQL query.
I am getting the error on line:
var Description = record.tables.EDP[steps.currentLoopCounter].fields.Description;
The script pulls data from the ODBC connection if I move the LookUp Table, ODBC Variables and Action below the repeat. It isn’t accurate as I have to hard coding the EDP table iteration [1], but at least I know my connection works:
var connectionURL = “jdbc:odbc:TrainingChecklist”;
var Description = record.tables.EDP[1].fields.Description;
//var Description = record.tables.EDP[steps.currentLoopCounter].fields.Description;
if(Description){
var csvConnection = db.connect(connectionURL,“”,“”);
var csvQuery = “SELECT * FROM "psocodes.csv" WHERE Description=” + “'” + Description + “'”;
logger.info(csvQuery);
resultSet = csvConnection.createStatement().executeQuery(csvQuery);
logger.info(resultSet);
resultSet.next();
}
Oh my goodness! I swear I tried that, but tried SO many variations that I may have just missed that in this one. Thank you. Sometimes it is just another set of eyes because everything seems to blur when you look at it for so long.