当前位置: 首页>>代码示例>>C++>>正文


C++ TeDatabasePortal::errorMessage方法代码示例

本文整理汇总了C++中TeDatabasePortal::errorMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ TeDatabasePortal::errorMessage方法的具体用法?C++ TeDatabasePortal::errorMessage怎么用?C++ TeDatabasePortal::errorMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TeDatabasePortal的用法示例。


在下文中一共展示了TeDatabasePortal::errorMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: insertRasterBlock

bool TeSQLite::insertRasterBlock(const string& table, const string& blockId, const TeCoord2D& ll, const TeCoord2D& ur, unsigned char *buf, unsigned long size, int band, unsigned int res, unsigned int subband)
{
	errorMessage_ = "";

	if (blockId.empty()) // no block identifier provided
	{
		errorMessage_ = "bloco sem identificador";
		return false;
	}

	TeDatabasePortal* portal = getPortal();
	bool insert = true;

	std::string sql = "SELECT block_id FROM " + table + " WHERE block_id='" + blockId + "'";
	if(!portal->query(sql))
	{
		delete portal;
		errorMessage_ = portal->errorMessage();
		
		return false;
	}

	if(portal->fetchRow())
	{
		insert = false;
	}

	delete portal;

	if(insert)
	{
		sql = "INSERT INTO " + table + " (lower_x, lower_y, upper_x, upper_y, band_id, resolution_factor, subband, block_size, spatial_data, block_id) ";
		sql += " VALUES (?,?,?,?,?,?,?,?,?,?)"; 
	}
	else
	{
		sql = "UPDATE " + table + " SET lower_x=?, lower_y=?, upper_x=?, upper_y=?, band_id=?,";
		sql += "resolution_factor=?, subband=?, block_size=?, spatial_data=? WHERE block_id=? ";
	}


	sqlite3_stmt* recordSet = 0;
	int retValue = sqlite3_prepare_v2(_conn, sql.c_str(), -1, &recordSet, 0);

	if(retValue != SQLITE_OK)
	{
		errorMessage_ = errorMessage();
		return false;
	}

	sqlite3_bind_double(recordSet, 1, ll.x());
	sqlite3_bind_double(recordSet, 2, ll.y());
	sqlite3_bind_double(recordSet, 3, ur.x());
	sqlite3_bind_double(recordSet, 4, ur.y());
	sqlite3_bind_int(recordSet, 5, band);
	sqlite3_bind_int(recordSet, 6, (int)res);
	sqlite3_bind_int(recordSet, 7, (int)subband);
	sqlite3_bind_int(recordSet, 8, (int)size);
	sqlite3_bind_blob(recordSet, 9, buf, size, SQLITE_TRANSIENT);
	sqlite3_bind_text(recordSet, 10, blockId.c_str(), blockId.size(), SQLITE_TRANSIENT);

	retValue = sqlite3_step(recordSet);
	if(retValue != SQLITE_DONE)
	{
		return false;
	}

	sqlite3_finalize(recordSet);

	return true;
}
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:71,代码来源:TeSQLite.cpp


注:本文中的TeDatabasePortal::errorMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。