void API::Update(SQLUpdate& statement) { if (current_db_.length() == 0) throw NoDatabaseSelectedException(); Database *db = catalog_m_->GetDB(current_db_); if (db == NULL) throw DatabaseNotExistException(); Table *tb = db->GetTable(statement.get_tb_name()); if (tb == NULL) throw TableNotExistException(); RecordManager *rm = new RecordManager(catalog_m_, buffer_m_, current_db_); rm->Update(statement); delete rm; }
/*更新数据*/ void API::Update(SQLUpdate& sql_statement) { if (current_database_.length() == 0)/*判断当前数据库是否选定*/ { throw NoDatabaseSelectedException(); } Database *db = catalog_manager_->GetDB(current_database_); if (db == NULL)/*判断当前数据库是否存在*/ { throw DatabaseNotExistException(); } Table *tb = db->GetTable(sql_statement.get_tb_name()); if (tb == NULL)/*判断数据表是否存在是否存在*/ { throw TableNotExistException(); } RecordManager *rm = new RecordManager(catalog_manager_, buffer_manager_, current_database_); rm->Update(sql_statement); delete rm; //cout << "更新数据" << endl; }