本文整理汇总了C++中Identifier::setFromSql方法的典型用法代码示例。如果您正苦于以下问题:C++ Identifier::setFromSql方法的具体用法?C++ Identifier::setFromSql怎么用?C++ Identifier::setFromSql使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Identifier
的用法示例。
在下文中一共展示了Identifier::setFromSql方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getCreateTriggerRelation
Relation* SqlStatement::getCreateTriggerRelation() const
{
if (objectTypeM == ntTrigger && databaseM
&& tokensM[identifierTokenIndexM + 1] == kwFOR
&& tokensM[identifierTokenIndexM + 2] == tkIDENTIFIER)
{
Identifier id;
std::map<int, wxString>::const_iterator ci =
tokenStringsM.find(identifierTokenIndexM+2);
id.setFromSql((*ci).second);
return databaseM->findRelation(id);
}
return 0;
}
示例2: getStatementsToExecute
// UDD = user defined domain
// AGD = auto generated domain (those starting with RDB$)
bool FieldPropertiesDialog::getStatementsToExecute(wxString& statements,
bool justCheck)
{
wxString colNameSql(Identifier::userString(textctrl_fieldname->GetValue()));
Identifier selDomain(choice_domain->GetStringSelection());
bool newDomain = getIsNewDomainSelected();
wxString selDatatype = choice_datatype->GetStringSelection();
wxString dtSize = textctrl_size->GetValue();
wxString dtScale = textctrl_scale->GetValue();
bool isNullable = !checkbox_notnull->IsChecked();
int n = choice_datatype->GetSelection();
if (n >= 0 && n < datatypescnt)
{
if (!datatypes[n].hasSize)
dtSize.Clear();
if (!datatypes[n].hasScale)
dtScale.Clear();
}
wxString alterTable = "ALTER TABLE " + tableM->getQuotedName() + " ";
enum unn { unnNone, unnBefore, unnAfter } update_not_null = unnNone;
// detect changes to existing field, create appropriate SQL actions
if (columnM)
{
// field name changed ?
// compare regardless of active quoting rules, so that name
// will remain unchanged if edit field contents haven't changed
// OR if the altered name would result in same SQL identifier
if (textctrl_fieldname->GetValue() == columnM->getName_()
|| colNameSql == columnM->getQuotedName())
{
// no changes -> use original name for all other statements
colNameSql = columnM->getQuotedName();
}
else
{
statements += alterTable + "ALTER " + columnM->getQuotedName()
+ " TO " + colNameSql + ";\n\n";
}
// domain changed ?
wxString type, size, scale, charset;
if (!getDomainInfo(columnM->getSource(), type, size, scale, charset))
{
::wxMessageBox(_("Can not get domain info - aborting."),
_("Error"), wxOK | wxICON_ERROR);
return false;
}
if (columnM->getSource() != selDomain.get() && !newDomain)
{ // UDD -> other UDD or AGD -> UDD
statements += alterTable + "ALTER " + colNameSql +
" TYPE " + selDomain.getQuoted() + ";\n\n";
}
else if (newDomain
|| type.CmpNoCase(selDatatype) || size != dtSize || scale != dtScale)
{ // UDD -> AGD or AGD -> different AGD
statements += alterTable + "ALTER " + colNameSql +
" TYPE ";
statements += selDatatype;
if (!dtSize.IsEmpty())
{
statements += "(" + dtSize;
if (!dtScale.IsEmpty())
statements += "," + dtScale;
statements += ")";
}
statements += ";\n\n";
}
// not null option changed ?
if (isNullable != columnM->isNullable(CheckDomainNullability))
{
if (!isNullable) // change from NULL to NOT NULL
update_not_null = unnBefore;
statements += "UPDATE RDB$RELATION_FIELDS SET RDB$NULL_FLAG = ";
if (isNullable)
statements += "NULL";
else
statements += "1";
// direct change in RDB$RELATION_FIELDS needs unquoted field name
Identifier id;
id.setFromSql(colNameSql);
wxString fnm = id.get();
fnm.Replace("'", "''");
wxString tnm = tableM->getName_();
statements += "\nWHERE RDB$FIELD_NAME = '" + fnm
+ "' AND RDB$RELATION_NAME = '" + tnm
+ "';\n\n";
if (isNullable) // change from NOT NULL to NULL
{
wxString constraintName;
if (getNotNullConstraintName(fnm, constraintName))
{
statements += alterTable + "DROP CONSTRAINT "
//.........这里部分代码省略.........
示例3: tokenizer
SqlStatement::SqlStatement(const wxString& sql, Database *db, const wxString&
terminator)
:actionM(actNONE), objectTypeM(ntUnknown), databaseM(db), objectM(0),
identifierTokenIndexM(0), isAlterColumnM(false), isDatatypeM(false),
terminatorM(terminator), statementM(sql)
{
// use the tokenizer to split the statements into a vector of tokens
// also keep the token strings for identifiers and strings
SqlTokenizer tokenizer(sql);
// first get the tokens up to the first identifier
SqlTokenType stt;
while (true)
{
stt = tokenizer.getCurrentToken();
if (stt == tkEOF)
break;
if (stt != tkCOMMENT && stt != tkWHITESPACE)
{
tokensM.add(stt);
wxString ts(tokenizer.getCurrentTokenString());
tokenStringsM[tokensM.size() - 1] = ts;
if (stt == tkIDENTIFIER)
{
nameM.setFromSql(ts);
tokenizer.jumpToken(false);
// break here since we don't want name to be overwritten
if (tokensM[0] != kwGRANT && tokensM[0] != kwREVOKE
&& tokensM[0] != kwCOMMENT)
{
break;
}
}
}
tokenizer.jumpToken(false);
}
// needs at least action
if (tokensM.size() < 1)
return; // true;
if (nameM.get().IsEmpty()) // non-reserved keyword used as identifier?
{
nameM.setFromSql(tokenStringsM[2]); // we take a lucky guess
identifierTokenIndexM = 2; // ex.: CREATE DOMAIN CASCADE
}
else
identifierTokenIndexM = tokensM.size() - 1;
size_t typeTokenIndex = 1;
// get action
switch (tokensM[0])
{
case kwALTER:
actionM = actALTER; break;
case kwCOMMENT:
actionM = actCOMMENT; break;
case kwCREATE:
actionM = actCREATE; break;
case kwDECLARE:
actionM = actDECLARE; break;
case kwDROP:
actionM = actDROP; break;
case kwGRANT:
case kwREVOKE:
actionM = actGRANT; break;
case kwRECREATE:
actionM = actRECREATE; break;
case kwSET:
actionM = actSET; break;
case kwUPDATE:
// it's the only statement we care for which has implicit type
actionM = actUPDATE; objectTypeM = ntTable; break;
default:
return; // true;
}
// special handling for "CREATE OR ALTER"
if (actionM == actCREATE && tokensM[1] == kwOR && tokensM[2] == kwALTER)
{
actionM = actCREATE_OR_ALTER;
typeTokenIndex = 3;
if (identifierTokenIndexM == 2)
{
identifierTokenIndexM = 4;
nameM.setFromSql(tokenStringsM[4]);
}
}
// GRANT blah, blah blah ON [PROCEDURE] object_name TO ...
// REVOKE blah, blah, .. ON [PROCEDURE] object_name FROM ...
if (actionM == actGRANT)
{
size_t idx = 1;
while (idx < tokensM.size())
{
if (tokensM[idx++] == kwON)
{
if (tokensM[idx] == kwPROCEDURE)
{
//.........这里部分代码省略.........