#include "sqlCheck.h" #include "xmlObjectLoader.h" #include "appEngine.h" #include "selectcommand.h" #include "column.h" #include "rdbmsDataSource.h" #include _SqlCheck::_SqlCheck(const xmlpp::Element * p) : _SourceObject(p), IHaveParameters(p), _ParamChecker(p), dataSource(p->get_attribute_value("datasource")), sql(xmlChildText(p, "sql")), testOp(p->get_attribute_value("testOp")), testValue(atof(p->get_attribute_value("testValue").c_str())) { } _SqlCheck::~_SqlCheck() { } bool _SqlCheck::performCheck(const ApplicationEngine * ep) const { ODBC::SelectCommand * query = new ODBC::SelectCommand(ep->dataSource<_RdbmsDataSource>(dataSource)->getReadonly(), sql); BOOST_FOREACH(Parameters::value_type p, parameters) { query->bindParamS(p.second->bind, p.second->value); } bool retVal = false; while (query->fetch()) { int val = (*query)[0]; if ((testOp == "==" || testOp == "=") && val == testValue) { retVal = true; } else if (testOp == "<" && val < testValue) { retVal = true; } else if (testOp == ">" && val > testValue) { retVal = true; } else if (testOp == "!=" && val != testValue) { retVal = true; } else if ((testOp == "<=" || testOp == "=<") && val <= testValue) { retVal = true; } else if ((testOp == ">=" || testOp == "=>") && val >= testValue) { retVal = true; } } delete query; return retVal; }