Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1028|回复: 0
打印 上一主题 下一主题

db数据库相关

[复制链接]

1228

主题

1996

帖子

7574

积分

认证用户组

Rank: 5Rank: 5

积分
7574
跳转到指定楼层
楼主
发表于 2020-1-28 18:33:11 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
//加上下面这个就可以直接用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;
}

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|firemail ( 粤ICP备15085507号-1 )

GMT+8, 2024-4-26 21:59 , Processed in 0.056224 second(s), 19 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表