firemail
标题:
db数据库相关
[打印本页]
作者:
Qter
时间:
2020-1-28 18:33
标题:
db数据库相关
//加上下面这个就可以直接用rs.get 获取 int64类型的程序
#ifndef _LINUX
#define WIN32_LEAN_AND_MEAN
#define OTL_BIGINT int64
#else
#if __LP64__
#else
#define OTL_BIGINT long int
#endif
#endif
bool CCdmaExtendDataManage::ReadCellDistanceMap()
{
string sSql = "select ne_cell_id,min(distance) as distince from NE_CELL_DISTANCE group by ne_cell_id";
otl_connect:
tl_initialize();
otl_connect db_conn_;
try{
char loginstring[128];
memset(loginstring, 0, sizeof(loginstring));
sprintf(loginstring,"%s/%s@%s", db_cfg_user_.c_str(), db_cfg_pwd_.c_str(), db_cfg_database_.c_str());
db_conn_.rlogon(loginstring); // connect to Oracle
otl_stream ne_cell_w(20000, // buffer size
sSql.c_str(), // SELECT statement
db_conn_ // connect object
);
otl_stream_read_iterator<otl_stream,otl_exception,otl_lob_stream> rs;
rs.attach(ne_cell_w);
while(rs.next_row())
{ // while not end-of-data
//CELLDISTANCEINFO* pDisInfo = new CELLDISTANCEINFO();
int64 ne_cell_id = 0;
double dintance = 0.0;
//char necellid[128];
//ZeroMemory(necellid,128);
int nRsIndex = 0; //otl index是从1开始的.kao.
rs.get(++nRsIndex, ne_cell_id);
//ne_cell_id=UWay::Util::atoi(necellid);
rs.get(++nRsIndex, (double&)dintance);
/*
if (!rs.is_null("ne_cell_id"))
{
rs.get("ne_cell_id", ne_cell_id);
////////// 方法1 ////////////////////
//char necellid[128];
//ZeroMemory(necellid,128);
//rs.get("ne_cell_id", necellid); //出错退出
//ne_cell_id=UWay::Util::atoi(necellid);
////////// 方法2 ////////////////////
//rs.get("ne_cell_id",(long int&)ne_cell_id); //已经越界
}
if (!rs.is_null("distince"))
{
rs.get("distince",(double&)dintance);
}
*/
g_mapCellDistance.insert(map<int64,double>::value_type(ne_cell_id,dintance));
//delete pDisInfo;
}
rs.detach();
db_conn_.logoff();
}
catch(otl_exception& p){ // intercept OTL exceptions
//LOG_ILAP_ERROR((char*)p.msg);
//LOG_ILAP_ERROR(p.stm_text);
//LOG_ILAP_ERROR(p.var_info);
return false;
}
return true;
}
欢迎光临 firemail (http://firemail.wang:8088/)
Powered by Discuz! X3