MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / getNextIndex

Method getNextIndex

src/utilities/sql/SqlFile_Impl.cpp:409–420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

407 }
408
409 int SqlFile_Impl::getNextIndex(const std::string& t_tableName, const std::string& t_columnName) {
410 // Interestingly, you CANNOT bind any database identifier (such as the table name / column name) but only litteral values...
411 // boost::optional<int> maxindex = execAndReturnFirstInt("SELECT MAX( ? ) FROM ?", t_columnName, t_tableName);
412 std::string query = "SELECT MAX(" + t_columnName + ") FROM " + t_tableName + ";";
413 boost::optional<int> maxindex = execAndReturnFirstInt(query);
414
415 if (maxindex) {
416 return *maxindex + 1;
417 } else {
418 return 1;
419 }
420 }
421
422 openstudio::path SqlFile_Impl::path() const {
423 return m_path;

Callers

nothing calls this directly

Calls 1

execAndReturnFirstIntFunction · 0.70

Tested by

no test coverage detected