if (regex_search(line, m, delete_command)) {
// regex delete_values_regex(R"(DELETE FROM (\w+)\s+WHERE\s+(\w+)\s*=\s*(\w+);)");
// smatch delete_match;
// if (regex_search(line, delete_match, delete_values_regex)) {
string table_name = m[1].str();
string condition_column = m[2].str();
string condition_value = m[3].str();
// Find the table and delete matching rows
// auto table_iter = find_if(tables.begin(), tables.end(),
// [&table_name](const pair& table) {
// return table.first == table_name;
// });
// if (table_iter != tables.end()) {
// auto& table_rows = table_iter->second;
// int condition_col_index = -1;
// Find the column index for the condition column
// for (int i = 0; i < table_rows[0].size(); ++i) {
// if (std::holds_alternative(table_rows[0]) && std::get(table_rows[0]) == condition_column) {
// condition_col_index = i;
// break;
// }
// }
// if (condition_col_index != -1) {
// Loop through rows and delete those that match the condition
// table_rows.erase(remove_if(table_rows.begin(), table_rows.end(), [&](const vector& row) {
// if (std::holds_alternative(row[condition_col_index])) {
// return std::get(row[condition_col_index]) == stoi(condition_value);
// } else if (std::holds_alternative(row[condition_col_index])) {
// return std::get(row[condition_col_index]) == condition_value;
// }
// return false;
// table_rows.erase(remove_if(table_rows.begin(), table_rows.end(),
// [&column_name, &value](const vector& row) {
// Logic to compare column value and delete row if matched
// }), table_rows.end());
// }
// }
auto table_it = find_if(tables.begin(), tables.end(), [&](const auto& t){
return t.first == table_name;
});
if (table_it != tables.end()) {
auto& table = table_it->second;
auto& headers = table[0];
int cond_col_index = -1;
// Find the column index for the condition column
for (int i = 0; i < headers.size(); ++i) {
if (get(headers) == condition_column) {
cond_col_index = i;
break;
}
}
if (cond_col_index != -1) {
cout " will not be added
processed_command_line_outputs.push_back(line);
cout
Подробнее здесь: https://stackoverflow.com/questions/793 ... -in-the-fi
Почему моя команда DELETE не работает и не меняет базу данных mdb в конечном выводе в терминале? ⇐ C++
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение