Forum Discussion

ilovechiku's avatar
ilovechiku
Contributor
10 years ago
Solved

Compare response to table values

I have a response(i have multiple such entries copied only one.) like below and I have a table that I need to compare it against.

{

"Items": [
{
"EmployeeId": "1",
"CompanyId": "1",
"FirstName": "SPENCER",
"LastName": "LIN"
"Status": {
"Code": "A",
"Description": "Active"
},
"BenefitClass": null,
"SupervisorId": null,
"SupervisorFirstName": null,
"SupervisorLastName": null,
"CostCenters": [
{
"Code": "01",
"Description": "Corporate"
}
]
}

 

I was able to print the results of the value in DB, like below:

/*****************************************this is the employeeId returned from DB.**************************************/
def returntripDB = getEmployeeFromDB(db,jsonRes)

returned DB value[[Id:1], [Id:113], [Id:129], [Id:130], [Id:131], [Id:134], [Id:136], [Id:140], [Id:143]]


public def getEmployeeFromDB(def database,jsonRes)
{
def query = "SELECT Id FROM [mydb].[mydb].[etable] order by etableid asc"
// log.info "QUERY for all employee id only "+query
return database.rows(query)

}

 

I want to iterate through the reponse and compare the values to the DB. How can i do this?