本文整理汇总了C++中DatabasePtr::loadIdentifiers方法的典型用法代码示例。如果您正苦于以下问题:C++ DatabasePtr::loadIdentifiers方法的具体用法?C++ DatabasePtr::loadIdentifiers怎么用?C++ DatabasePtr::loadIdentifiers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabasePtr
的用法示例。
在下文中一共展示了DatabasePtr::loadIdentifiers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleURI
bool AddConstraintHandler::handleURI(URI& uri)
{
if (uri.action != "add_constraint")
return false;
wxString type = uri.getParam("type"); // pk, fk, check, unique
Table* t = extractMetadataItemFromURI<Table>(uri);
wxWindow* w = getParentWindow(uri);
if (!t || !w)
return true;
// Find first available constraint name:
DatabasePtr db = t->getDatabase();
wxString prefix = type + "_" + t->getName_();
wxString stmt(
"select rdb$constraint_name from rdb$relation_constraints "
"where rdb$relation_name = '" + t->getName_() +
"' and rdb$constraint_name starting with '" + prefix +
"' order by 1");
wxString default_value;
wxArrayString constraintNames(db->loadIdentifiers(stmt));
for (int i = 0; ; ++i)
{
default_value = prefix + wxString::Format("_%d", i);
if (constraintNames.Index(default_value, false) == wxNOT_FOUND)
break;
}
wxString cname = ::wxGetTextFromUser(_("Enter constraint name"),
_("Adding new table constraint"), default_value, w);
if (cname.IsEmpty()) // cancel
return true;
wxString sql = "alter table " + t->getQuotedName() +
"\nadd constraint " + Identifier::userString(cname);
if (type == "PK")
{
wxString columnlist = selectRelationColumns(t, w);
if (columnlist.IsEmpty()) // cancel
return true;
sql += "\nprimary key (" + columnlist + ")";
}
else if (type == "FK")
{
wxString columnlist = selectRelationColumns(t, w);
if (columnlist == "")
return true;
TablePtr ref = selectTable(t->getDatabase(), w);
if (!ref)
return true;
wxString refcolumnlist = selectRelationColumns(ref.get(), w);
if (refcolumnlist == "")
return true;
sql += "\nforeign key (" + columnlist + ") \nreferences " + ref->getQuotedName()
+ " (" + refcolumnlist + ")";
wxString action = selectAction(_("update"), w);
if (action == "CANCEL")
return true;
else if (action != "RESTRICT")
sql += "\non update " + action + " ";
action = selectAction(_("delete"), w);
if (action == "CANCEL")
return true;
else if (action != "RESTRICT")
sql += "\non delete " + action + " ";
}
else if (type == "CHK")
{
wxString source;
if (!GetMultilineTextFromUser(w, _("Enter check condition"), source))
return true;
sql += "\ncheck (" + source + ")";
}
else if (type == "UNQ")
{
wxString columnlist = selectRelationColumns(t, w);
if (columnlist.IsEmpty()) // cancel
return true;
sql += "\nunique (" + columnlist + ")";
}
else
{
::wxMessageBox(_("Unknown constraint type"), _("Error."), wxOK | wxICON_ERROR);
return true;
}
execSql(w, "", db, sql, true); // true = commit + close at once
return true;
}