wxString dlgForeignServer::GetSql() { wxString sql, name; name = txtName->GetValue(); if (foreignserver) { // edit mode AppendNameChange(sql, wxT("SERVER ") + qtIdent(foreignserver->GetName())); if (txtVersion->GetValue() != foreignserver->GetVersion()) { sql = wxT("ALTER SERVER ") + qtIdent(name) + wxT("\n VERSION ") + qtDbString(txtVersion->GetValue()) + wxT(";\n"); } wxString sqloptions = GetOptionsSql(); if (sqloptions.Length() > 0) { sql += wxT("ALTER SERVER ") + name + wxT("\n OPTIONS (") + sqloptions + wxT(");\n"); } AppendOwnerChange(sql, wxT("SERVER ") + qtIdent(name)); } else { // create mode sql = wxT("CREATE SERVER ") + qtIdent(name); if (!(txtType->GetValue()).IsEmpty()) sql += wxT("\n TYPE ") + qtDbString(txtType->GetValue()); if (!(txtVersion->GetValue()).IsEmpty()) sql += wxT("\n VERSION ") + qtDbString(txtVersion->GetValue()); sql += wxT("\n FOREIGN DATA WRAPPER ") + qtIdent(foreigndatawrapper->GetName()); // check for options if (lstOptions->GetItemCount() > 0) { wxString options = wxEmptyString; for (int pos = 0 ; pos < lstOptions->GetItemCount() ; pos++) { if (options.Length() > 0) options += wxT(", "); options += lstOptions->GetText(pos, 0) + wxT(" '") + lstOptions->GetText(pos, 1) + wxT("' "); } sql += wxT("\n OPTIONS (") + options + wxT(")"); } sql += wxT(";\n"); AppendOwnerNew(sql, wxT("SERVER ") + qtIdent(name)); } sql += GetGrant(wxT("U"), wxT("SERVER ") + qtIdent(name)); AppendComment(sql, wxT("SERVER"), 0, foreignserver); return sql; }
void dlgUserMapping::CheckChange() { bool didChange = true; if (usermapping) { didChange = GetOptionsSql().Length() > 0; EnableOK(didChange); } else { bool enable = true; CheckValid(enable, !cbUser->GetValue().IsEmpty(), _("Please specify user.")); EnableOK(enable); } }
void dlgTextSearchDictionary::CheckChange() { if (dict) { EnableOK(txtName->GetValue() != dict->GetName() || txtComment->GetValue() != dict->GetComment() || cbOwner->GetValue() != dict->GetOwner() || GetOptionsSql().Length() > 0); } else { wxString name=GetName(); bool enable=true; CheckValid(enable, !name.IsEmpty(), _("Please specify name.")); CheckValid(enable, cbTemplate->GetValue().Length() > 0 , _("Please select a template.")); EnableOK(enable); } }
wxString dlgTextSearchDictionary::GetSql() { wxString sql; wxString objname=schema->GetQuotedPrefix() + qtIdent(GetName()); if (dict) { // edit mode AppendNameChange(sql); AppendOwnerChange(sql, wxT("TEXT SEARCH DICTIONARY ") + objname); wxString sqloptions = GetOptionsSql(); if (sqloptions.Length() > 0) { sql += wxT("ALTER TEXT SEARCH DICTIONARY ") + objname + wxT(" (") + sqloptions + wxT(")"); } } else { // create mode sql = wxT("CREATE TEXT SEARCH DICTIONARY ") + schema->GetQuotedPrefix() + GetName() + wxT(" (") + wxT("\n TEMPLATE = ") + cbTemplate->GetValue(); // check for options for (int pos=0 ; pos < lstOptions->GetItemCount() ; pos++) { sql += wxT(", ") + lstOptions->GetText(pos, 0) + wxT("=") + lstOptions->GetText(pos, 1); } sql += wxT("\n);\n"); } AppendComment(sql, wxT("TEXT SEARCH DICTIONARY ") + objname, dict); return sql; }
void dlgForeignServer::CheckChange() { bool didChange = true; wxString name = txtName->GetValue(); if (foreignserver) { didChange = name != foreignserver->GetName() || txtComment->GetValue() != foreignserver->GetComment() || cbOwner->GetValue() != foreignserver->GetOwner() || txtType->GetValue() != foreignserver->GetType() || txtVersion->GetValue() != foreignserver->GetVersion() || GetOptionsSql().Length() > 0; EnableOK(didChange); } else { bool enable = true; CheckValid(enable, !name.IsEmpty(), _("Please specify name.")); EnableOK(enable); } }
void dlgForeignDataWrapper::CheckChange() { bool didChange = true; wxString name = txtName->GetValue(); if (fdw) { didChange = name != fdw->GetName() || cbOwner->GetValue() != fdw->GetOwner() || txtComment->GetValue() != fdw->GetComment() || cbHandler->GetValue() != fdw->GetHandlerProc() || cbValidator->GetValue() != fdw->GetValidatorProc() || GetOptionsSql().Length() > 0; EnableOK(didChange); } else { bool enable = true; CheckValid(enable, !name.IsEmpty(), _("Please specify name.")); EnableOK(enable); } }
wxString dlgUserMapping::GetSql() { wxString sql; if (usermapping) { // edit mode wxString sqloptions = GetOptionsSql(); if (sqloptions.Length() > 0) { sql += wxT("ALTER USER MAPPING FOR ") + usermapping->GetUsr() + wxT(" SERVER ") + foreignserver->GetName() + wxT("\n OPTIONS (") + sqloptions + wxT(");\n"); } } else { // create mode sql = wxT("CREATE USER MAPPING FOR ") + cbUser->GetValue() + wxT(" SERVER ") + foreignserver->GetName(); // check for options if (lstOptions->GetItemCount() > 0) { wxString options = wxEmptyString; for (int pos = 0 ; pos < lstOptions->GetItemCount() ; pos++) { if (options.Length() > 0) options += wxT(", "); options += lstOptions->GetText(pos, 0) + wxT(" '") + lstOptions->GetText(pos, 1) + wxT("' "); } sql += wxT("\n OPTIONS (") + options + wxT(")"); } sql += wxT(";\n"); } return sql; }
wxString dlgForeignDataWrapper::GetSql() { wxString sql, name; name = txtName->GetValue(); if (fdw) { // edit mode sql = wxEmptyString; AppendNameChange(sql); if (cbHandler->GetValue() != fdw->GetHandlerProc()) { if (cbHandler->GetValue().IsEmpty()) sql += wxT("ALTER FOREIGN DATA WRAPPER ") + qtIdent(name) + wxT("\n NO HANDLER;\n"); else sql += wxT("ALTER FOREIGN DATA WRAPPER ") + qtIdent(name) + wxT("\n HANDLER ") + qtIdent(cbHandler->GetValue()) + wxT(";\n"); } if (cbValidator->GetValue() != fdw->GetValidatorProc()) { if (cbValidator->GetValue().IsEmpty()) sql += wxT("ALTER FOREIGN DATA WRAPPER ") + qtIdent(name) + wxT("\n NO VALIDATOR;\n"); else sql += wxT("ALTER FOREIGN DATA WRAPPER ") + qtIdent(name) + wxT("\n VALIDATOR ") + qtIdent(cbValidator->GetValue()) + wxT(";\n"); } wxString sqloptions = GetOptionsSql(); if (sqloptions.Length() > 0) { sql += wxT("ALTER FOREIGN DATA WRAPPER ") + name + wxT(" OPTIONS (") + sqloptions + wxT(");"); } AppendOwnerChange(sql, wxT("FOREIGN DATA WRAPPER ") + qtIdent(name)); } else { // create mode sql = wxT("CREATE FOREIGN DATA WRAPPER ") + qtIdent(name); AppendIfFilled(sql, wxT("\n HANDLER "), qtIdent(cbHandler->GetValue())); AppendIfFilled(sql, wxT("\n VALIDATOR "), qtIdent(cbValidator->GetValue())); // check for options if (lstOptions->GetItemCount() > 0) { wxString options = wxEmptyString; for (int pos = 0 ; pos < lstOptions->GetItemCount() ; pos++) { if (options.Length() > 0) options += wxT(", "); options += lstOptions->GetText(pos, 0) + wxT(" '") + lstOptions->GetText(pos, 1) + wxT("' "); } sql += wxT("\n OPTIONS (") + options + wxT(")"); } sql += wxT(";\n"); AppendOwnerNew(sql, wxT("FOREIGN DATA WRAPPER ") + qtIdent(name)); } sql += GetGrant(wxT("U"), wxT("FOREIGN DATA WRAPPER ") + qtIdent(name)); AppendComment(sql, wxT("FOREIGN DATA WRAPPER"), 0, fdw); return sql; }
wxString dlgForeignTable::GetSql() { wxString sql; wxString name; if (foreigntable) { // Edit Mode name = qtIdent(foreigntable->GetSchema()->GetName()) + wxT(".") + qtIdent(GetName()); AppendNameChange(sql, wxT("FOREIGN TABLE ") + foreigntable->GetQuotedFullIdentifier()); AppendOwnerChange(sql, wxT("FOREIGN TABLE ") + name); sql += GetSqlForTypes(); wxString sqloptions = GetOptionsSql(); if (sqloptions.Length() > 0) { sql += wxT("ALTER FOREIGN TABLE ") + name + wxT("\n OPTIONS (") + sqloptions + wxT(");\n"); } AppendSchemaChange(sql, wxT("FOREIGN TABLE ") + name); } else { name = qtIdent(cbSchema->GetValue()) + wxT(".") + qtIdent(GetName()); // Create Mode sql = wxT("CREATE FOREIGN TABLE " + name); sql += wxT(" ("); int i; for (i = 0 ; i < lstMembers->GetItemCount() ; i++) { if (i) sql += wxT(",\n "); sql += qtIdent(lstMembers->GetItemText(i)) + wxT(" ") + GetFullTypeName(i); } sql += wxT(") SERVER ") + cbForeignServer->GetValue(); // check for options if (lstOptions->GetItemCount() > 0) { wxString options = wxEmptyString; for (int pos = 0 ; pos < lstOptions->GetItemCount() ; pos++) { if (options.Length() > 0) options += wxT(", "); options += lstOptions->GetText(pos, 0) + wxT(" '") + lstOptions->GetText(pos, 1) + wxT("' "); } sql += wxT("\n OPTIONS (") + options + wxT(")"); } sql += wxT(";\n"); } AppendComment(sql, wxT("FOREIGN TABLE ") + qtIdent(cbSchema->GetValue()) + wxT(".") + qtIdent(GetName()), foreigntable); if (seclabelPage && connection->BackendMinimumVersion(9, 1)) sql += seclabelPage->GetSqlForSecLabels(wxT("FOREIGN TABLE "), qtIdent(cbSchema->GetValue()) + wxT(".") + qtIdent(GetName())); return sql; }