本文整理汇总了C++中TeDatabasePortal::freeResult方法的典型用法代码示例。如果您正苦于以下问题:C++ TeDatabasePortal::freeResult方法的具体用法?C++ TeDatabasePortal::freeResult怎么用?C++ TeDatabasePortal::freeResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TeDatabasePortal
的用法示例。
在下文中一共展示了TeDatabasePortal::freeResult方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getIndexesFromTable
bool TeSQLite::getIndexesFromTable(const string& tableName, std::vector<TeDatabaseIndex>& vecIndexes)
{
TeDatabasePortal* portal = getPortal();
std::string sqlIndexes = "PRAGMA index_list(" + tableName + ");";
if(portal->query(sqlIndexes) == false)
{
delete portal;
return false;
}
while(portal->fetchRow())
{
TeDatabaseIndex dbIndex;
dbIndex.setIndexName(portal->getData("name"));
vecIndexes.push_back(dbIndex);
}
portal->freeResult();
for(unsigned int i = 0; i < vecIndexes.size(); ++i)
{
std::string sqlIndex = "PRAGMA index_info(" + vecIndexes[i].getIndexName() + ");";
if(portal->query(sqlIndex) == false)
{
delete portal;
return false;
}
std::vector<std::string> vecColumns;
while(portal->fetchRow())
{
vecColumns.push_back(portal->getData("name"));
}
portal->freeResult();
vecIndexes[i].setColumns(vecColumns);
}
delete portal;
return true;
}
示例2: if
vector<string> getObjects(TeTheme* theme, vector<string>& itens)
{
vector<string> svec;
if(!theme)
return svec;
TeDatabase* db = 0;
if(theme->getProductId() == TeEXTERNALTHEME)
db = static_cast<TeExternalTheme*>(theme)->getSourceDatabase();
else if(theme->getProductId() == TeTHEME)
db = static_cast<TeTheme*>(theme)->layer()->database();
if(db == 0)
return svec;
TeDatabasePortal* portal = db->getPortal();
string C = theme->collectionTable();
string CA = theme->collectionAuxTable();
string query = "SELECT " + C + ".c_object_id FROM " + C + " LEFT JOIN " + CA;
query += " ON " + C + ".c_object_id = " + CA + ".object_id";
query += " WHERE " + CA + ".unique_id IN ";
set<string> idSet;
vector< string >::iterator it_begin = itens.begin();
vector< string >::iterator it_end = itens.end();
vector<string> inVec = generateInClauses(it_begin, it_end, db, false);
vector<string>::iterator it;
for(it=inVec.begin(); it!=inVec.end(); ++it)
{
if((*it).empty() == false)
{
string sel = query + *it;
if (portal->query(sel) == false)
{
delete portal;
return svec;
}
while (portal->fetchRow())
idSet.insert(portal->getData(0));
portal->freeResult();
}
}
delete portal;
set<string>::iterator sit;
for(sit=idSet.begin(); sit!=idSet.end(); ++sit)
svec.push_back(*sit);
return svec;
}
示例3: updateDB301To302
bool updateDB301To302(TeDatabase* db, string& errorMessage)
{
TeDatabasePortal* portal = db->getPortal();
if(!portal)
return false;
// ----- valid attribute table
TeAttrTableVector attrTableVec;
if(db->getAttrTables(attrTableVec))
{
for(unsigned int i=0; i<attrTableVec.size(); ++i)
{
TeTable fromTable = attrTableVec[i];
bool flag = false;
if(fromTable.tableType()==TeAttrMedia)
continue;
//verify if there is another table with the same name
for(unsigned int j=0; j<i; ++j)
{
if(TeConvertToUpperCase(attrTableVec[j].name())==TeConvertToUpperCase(fromTable.name()))
{
flag = true;
break;
}
}
if(flag)
continue;
if(db->validTable(fromTable)) //fromTable was modified
{
TeAttributeList newAttrList = fromTable.attributeList();
TeAttributeList oldAttrList = attrTableVec[i].attributeList();
TeAttributeList::iterator newAttIt = newAttrList.begin();
TeAttributeList::iterator oldAttIt = oldAttrList.begin();
bool change = false;
while(newAttIt!=newAttrList.end())
{
if(((*oldAttIt).rep_.name_) != ((*newAttIt).rep_.name_))
{
TeAttributeRep rep = (*newAttIt).rep_;
if(db->alterTable(fromTable.name(), rep, (*oldAttIt).rep_.name_))
change = true;
}
++newAttIt;
++oldAttIt;
}
if(change)
{
// update te_layer_table
string upd = " UPDATE te_layer_table ";
upd += " SET unique_id = '"+ fromTable.uniqueName() +"'";
upd += ", attr_link = '"+ fromTable.linkName() +"'";
upd += " WHERE attr_table = '"+ fromTable.name() +"'";
if(!db->execute (upd))
{
delete portal;
errorMessage = "Error updating te_layer_table!\n";
errorMessage += db->errorMessage();
return false;
}
}
}//if
}//for
portal->freeResult();
}
// ----- te_grouping table
string sel = " SELECT theme_id, grouping_attr, grouping_attr_type FROM te_grouping ";
if(!portal->query(sel))
{
delete portal;
return false;
}
while(portal->fetchRow())
{
string themeId, gAttr;
themeId = portal->getData(0);
gAttr = portal->getData(1);
int gTypr = portal->getInt(2);
if(((gAttr.empty()) || (gAttr=="NONE")) && (gTypr==0))
{
string del = " DELETE FROM te_grouping WHERE theme_id = "+ themeId;
db->execute(del);
}
}
// ----- te_grouping table
//.........这里部分代码省略.........
示例4: updateDB20To30
//.........这里部分代码省略.........
up += " WHERE c_object_status = " + Te2String(theme->pointingLegend().id());
db->execute(up);
up = "UPDATE " + theme->collectionTable() + " SET c_object_status = 2";
up += " WHERE c_object_status = " + Te2String(theme->queryLegend().id());
db->execute(up);
up = "UPDATE " + theme->collectionTable() + " SET c_object_status = 3";
up += " WHERE c_object_status = " + Te2String(theme->queryAndPointingLegend().id());
db->execute(up);
if ((!theme->createCollectionAuxTable()) || (!theme->populateCollectionAux()))
{
errorMessage = "Fail to mount the auxiliary table of the collection!\n";
errorMessage += db->errorMessage();
delete portal;
return false;
}
theme->collectionAuxTable(collExtTable);
theme->addThemeTable(collExtTable);
string oldTCE = theme->collectionTable() + "_ext";
if (db->tableExist(oldTCE))
{
string delTable = "DROP TABLE " + oldTCE;
db->execute(delTable);
}
}
}
//------------ end auxiliary collection
portal->freeResult();
//------------ text table
// if text table have not text visual table associated, create it
string sel = "SELECT geom_table FROM te_representation WHERE";
sel += " geom_type = " + Te2String(TeTEXT);
if(portal->query(sel))
{
while(portal->fetchRow())
{
string table = portal->getData(0);
string tvis = table + "_txvisual";
if(!db->tableExist(tvis))
{
TeAttributeList atl;
TeAttribute at;
at.rep_.name_ = "geom_id";
at.rep_.type_ = TeINT;
at.rep_.numChar_ = 0;
at.rep_.isPrimaryKey_ = true;
atl.push_back(at);
at.rep_.isPrimaryKey_ = false;
at.rep_.name_ = "dot_height";
at.rep_.type_ = TeINT;
atl.push_back(at);
at.rep_.name_ = "fix_size";
at.rep_.type_ = TeINT;
atl.push_back(at);
at.rep_.name_ = "color";
示例5: updateDB400To412
bool updateDB400To412(TeDatabase* db, string& errorMessage)
{
// ----- create the datum table
if(!db->createDatumTable())
{
errorMessage = "Error creating the datum table.\n";
errorMessage += db->errorMessage();
return false;
}
// ----- create the SRS table
if(!db->createSRSTable())
{
errorMessage = "Error creating the SRS table.\n";
errorMessage += db->errorMessage();
return false;
}
// ----- populate the datum table with pre-defined datums and ellipsoids
db->populateDatumTable();
// ----- change te_projection table: removed the columns associated with datum
if(!db->deleteColumn("te_projection", "radius"))
{
errorMessage = "Error removing the column radius from te_projection table.\n";
errorMessage += db->errorMessage();
return false;
}
if(!db->deleteColumn("te_projection", "flattening"))
{
errorMessage = "Error removing the column flattening from te_projection table.\n";
errorMessage += db->errorMessage();
return false;
}
if(!db->deleteColumn("te_projection", "dx"))
{
errorMessage = "Error removing the column dx from te_projection table.\n";
errorMessage += db->errorMessage();
return false;
}
if(!db->deleteColumn("te_projection", "dy"))
{
errorMessage = "Error removing the column dy from te_projection table.\n";
errorMessage += db->errorMessage();
return false;
}
if(!db->deleteColumn("te_projection", "dz"))
{
errorMessage = "Error removing the column dz from te_projection table.\n";
errorMessage += db->errorMessage();
return false;
}
// ----- END: change te_projection table: removed the columns associated with datum
// ----- relations
if(!db->createRelation("fk_proj_datum_name", "te_projection", "datum", "te_datum", "name", false))
{
errorMessage = "Error creating foreign key in the projection table.\n";
errorMessage += db->errorMessage();
return false;
}
if(!db->createRelation("fk_srs_proj_id", "te_srs", "projection_id", "te_projection", "projection_id", true))
{
errorMessage = "Error creating foreign key in the srs table.\n";
errorMessage += db->errorMessage();
return false;
}
// ----- populate te_srs table
TeDatabasePortal* portal = db->getPortal();
if(!portal)
{
errorMessage = "Error getting the database portal";
return false;
}
std::string sql = "SELECT te_projection.*, te_datum.radius, te_datum.flattening, te_datum.dx, te_datum.dy, te_datum.dz ";
sql += "FROM te_projection LEFT JOIN te_datum ON te_projection.datum = te_datum.name ";
if (!portal->query(sql))
return false;
while(portal->fetchRow())
{
TeProjection* proj = 0;
portal->getProjection(&proj);
if(proj)
db->insertSRSId(proj, proj->epsgCode());
delete proj;
}
portal->freeResult();
delete portal;
return true;
//.........这里部分代码省略.........
示例6: updateDB320To3201
//.........这里部分代码省略.........
TeBox bpol;
if (db->getMBRSelectedObjects(geomTable,"spatial_data", sqlfrom, "","",TeCELLS,bpol))
updateBox(bb,bpol);
}
if (theme.layer()->hasGeometry(TeTEXT))
{
geomTable = theme.layer()->tableName(TeTEXT);
sqlfrom = colTabName + " LEFT JOIN " + geomTable;
sqlfrom += " ON " + colTabName + ".c_object_id = " + geomTable + ".object_id";
TeBox bpol;
if (db->getMBRSelectedObjects(geomTable,"spatial_data", sqlfrom, "","",TeTEXT,bpol))
updateBox(bb,bpol);
}
}
//update theme box
string update = "UPDATE te_theme SET ";
update += " lower_x = " + Te2String(bb.x1());
update += ", lower_y = " + Te2String(bb.y1());
update += ", upper_x = " + Te2String(bb.x2());
update += ", upper_y = " + Te2String(bb.y2());
update += " WHERE theme_id=" + Te2String (theme.id());
if(!db->execute(update))
{
delete portal;
errorMessage = "Error updating theme box!\n";
errorMessage += db->errorMessage();
return false;
}
}
db->clear();
portal->freeResult();
db->user(originalUser);
//fill the box view
sql = "SELECT view_id, MIN(lower_x), MIN(lower_y), MAX(upper_x), MAX(upper_y) ";
sql += " FROM te_theme GROUP BY view_id ";
if(!portal->query(sql))
{
delete portal;
return false;
}
while(portal->fetchRow())
{
string viewId = string(portal->getData(0));
string update = " UPDATE te_view SET ";
update += " lower_x = "+ string(portal->getData(1));
update += ", lower_y = "+ string(portal->getData(2));
update += ", upper_x = "+ string(portal->getData(3));
update += ", upper_y = "+ string(portal->getData(4));
update += ", current_theme = NULL ";
update += " WHERE view_id = "+ viewId;
if(!db->execute(update))
{
delete portal;
errorMessage = "Error updating view box!\n";
errorMessage += db->errorMessage();
return false;
}
}