DBI::Error Transaction::truncate(const AnyString& tablename) { if (YUNI_UNLIKELY(not IsValidIdentifier(tablename))) return errInvalidIdentifier; assert(!(!pChannel)); // the adapter ::yn_dbi_adapter& adapter = pChannel->adapter; // The DBI interface should provide the most appropriate way for // truncating a table (autoincrement / cascade...) if (YUNI_LIKELY(adapter.truncate)) { return (DBI::Error) adapter.truncate(adapter.dbh, tablename.c_str(), tablename.size()); } else { // Fallback to a failsafe method // -- stmt << "TRUNCATE " << tablename << ';'; // The SQL command Truncate is not supported by all databases. `DELETE FROM` // is not the most efficient way for truncating a table // but it should work almost everywhere String stmt; stmt << "DELETE FROM " << tablename << ';'; return perform(stmt); } }
bool OnOk(const std::_tstring & label, std::_tstring &error_title, std::_tstring &error_msg) { if (IsValidIdentifier(label)) { if (!m_repository->WorkspaceExists(label)) return true; error_title = ERR_INVALID_IDENTIFIER_TITLE; error_msg = ERR_IDENTIFIER_EXISTS_AS_WORKSPACE; m_errExists = true; } else { error_title = ERR_INVALID_IDENTIFIER_TITLE; error_msg = ERR_INVALID_IDENTIFIER_WORKSPACE; } return false; }
bool OnOk(const std::_tstring & label, IAttributeType * type, std::_tstring &error_title, std::_tstring &error_msg) { if (IsValidIdentifier(label)) { CComPtr<IRepository> rep = ::AttachRepository(); ATLASSERT(m_module.length()); if (!rep->AttributeExists(m_module.c_str(), label.c_str(), type)) { return true; } error_title = ERR_INVALID_IDENTIFIER_TITLE; error_msg = ERR_IDENTIFIER_EXISTS_AS_ATTRIBUTE; } else { error_title = ERR_INVALID_IDENTIFIER_TITLE; error_msg = ERR_INVALID_IDENTIFIER; } return false; }
bool OnOk(const std::_tstring & label, std::_tstring &error_title, std::_tstring &error_msg) { if (IsValidIdentifier(label)) { std::_tstring qualifiedLabel; if (m_parent) qualifiedLabel = std::_tstring(m_parent->GetQualifiedLabel()) + _T("."); qualifiedLabel += label; CComPtr<IRepository> rep = ::AttachRepository(); if (!rep->ModuleExists(qualifiedLabel.c_str())) { return true; } error_title = ERR_INVALID_IDENTIFIER_TITLE; error_msg = ERR_IDENTIFIER_EXISTS_AS_MODULE; } else { error_title = ERR_INVALID_IDENTIFIER_TITLE; error_msg = ERR_INVALID_IDENTIFIER; } return false; }