当前位置: 技术问答>linux和unix
大家帮我看下下面的程序有没有问题,特别关注红色字体处,那里到底不要关闭游标。
来源: 互联网 发布时间:2016-09-01
本文导语: VOS_INT32 reSetPrefixInfo() { LOG_DEB.debug("debug:%s,%d,%s", __FILE__ , __LINE__,"enter LOG_Ap_Buf::reSetPrefixInfo()"); VOS_INT32 iRes = VOS_OK; string strTmp; set sstrLocalNum;//»º´æ int i, nFetch; bool bInfo = false; //Î...
VOS_INT32 reSetPrefixInfo()
{
LOG_DEB.debug("debug:%s,%d,%s", __FILE__ , __LINE__,"enter LOG_Ap_Buf::reSetPrefixInfo()");
VOS_INT32 iRes = VOS_OK;
string strTmp;
set sstrLocalNum;//»º´æ
int i, nFetch;
bool bInfo = false; //Ϊtrue˵Ã÷Ҫͬ²½µÄ±íÖÐÓÐÄÚÈÝ
ACE_GUARD_RETURN(MUTEX, mon, m_mutex_Prefix, -1);
struct sqlca sqlca;
DBAccess prefixDBAccesser;
//extern vector v_dbaccess;
//v_dbaccess.push_back(&prefixDBAccesser);
EXEC SQL BEGIN DECLARE SECTION;
char sUserName[30];
char sPassWord[30];
char sSID[30];
char PrefixNum[10][7+1];
sql_context cur_cxt; //Êý¾Ý¿âÁ¬½Ó
EXEC SQL END DECLARE SECTION;
prefixDBAccesser.Init(g_strDbLogUser.c_str(),g_strDbLogPwd.c_str(),g_strDbLogUrl.c_str());
iRes = prefixDBAccesser.Connect();
if(iRes != VOS_OK)
{
strTmp = "";
strTmp = strTmp +INFO_AP_BUF_CONN_FAILED + "T_MISC_PREFIX"+"( get DB connect error)";
LOG_AP.alert(LOG_FILE_FARMAT_OUT,strTmp.c_str());
// ALARM_AP(LOG_Alarm::ALERT, strTmp.c_str(),LOG_Alarm::DATABASE);
LOG_AP.error("error:%s,%d,%s", __FILE__ , __LINE__,"get DB connect error");
return -1;
}
LOG_AP.info("prefixDBAccesser connect success.");
cur_cxt = prefixDBAccesser.getSqlContext();
EXEC SQL CONTEXT USE :cur_cxt;
EXEC SQL DECLARE sql_cursor_prefix CURSOR FOR SELECT PrefixNum FROM T_MISC_PREFIX;
EXEC SQL OPEN sql_cursor_prefix;
#ifdef _DEBUG
LOG_AP.alert(LOG_OUT_FMT("%s",
"ntEXEC SQL DECLARE sql_cursor_prefix CURSOR FOR "
"SELECT PrefixNum FROM T_MISC_PREFIX;"));
#endif
//»ñÈ¡ËùÓмǼÐÅÏ¢
for (;;)
{
if (NOFOUND == sqlca.sqlcode)
{
#ifdef _DEBUG
LOG_AP.fatal(LOG_OUT_FMT("%s", "Record Not Found from T_MISC_PREFIX!"));
#endif
break;
}
else if (sqlca.sqlcode != 0)
{
strTmp = sqlca.sqlerrm.sqlerrmc;
strTmp = LOG_Util_String_Op::getLine(strTmp);
LOG_AP.alert(LOG_FILE_FARMAT_OUT,strTmp.c_str());
ALARM_AP(LOG_Alarm::ALERT, strTmp.c_str(),LOG_Alarm::DATABASE);
LOG_AP.error("error:%s,%d,%s", __FILE__ , __LINE__,strTmp.c_str());
return -1; //--这里需要关闭游标吗?
}
i = sqlca.sqlerrd[2];
if (i > 0)
{
//ÓÐÄÚÈÝ£¬ÉèÖñêÖ¾
bInfo = true;
}
EXEC SQL FETCH sql_cursor_prefix INTO :PrefixNum;
nFetch = sqlca.sqlerrd[2] - i;
for (i=0; i
{
LOG_DEB.debug("debug:%s,%d,%s", __FILE__ , __LINE__,"enter LOG_Ap_Buf::reSetPrefixInfo()");
VOS_INT32 iRes = VOS_OK;
string strTmp;
set sstrLocalNum;//»º´æ
int i, nFetch;
bool bInfo = false; //Ϊtrue˵Ã÷Ҫͬ²½µÄ±íÖÐÓÐÄÚÈÝ
ACE_GUARD_RETURN(MUTEX, mon, m_mutex_Prefix, -1);
struct sqlca sqlca;
DBAccess prefixDBAccesser;
//extern vector v_dbaccess;
//v_dbaccess.push_back(&prefixDBAccesser);
EXEC SQL BEGIN DECLARE SECTION;
char sUserName[30];
char sPassWord[30];
char sSID[30];
char PrefixNum[10][7+1];
sql_context cur_cxt; //Êý¾Ý¿âÁ¬½Ó
EXEC SQL END DECLARE SECTION;
prefixDBAccesser.Init(g_strDbLogUser.c_str(),g_strDbLogPwd.c_str(),g_strDbLogUrl.c_str());
iRes = prefixDBAccesser.Connect();
if(iRes != VOS_OK)
{
strTmp = "";
strTmp = strTmp +INFO_AP_BUF_CONN_FAILED + "T_MISC_PREFIX"+"( get DB connect error)";
LOG_AP.alert(LOG_FILE_FARMAT_OUT,strTmp.c_str());
// ALARM_AP(LOG_Alarm::ALERT, strTmp.c_str(),LOG_Alarm::DATABASE);
LOG_AP.error("error:%s,%d,%s", __FILE__ , __LINE__,"get DB connect error");
return -1;
}
LOG_AP.info("prefixDBAccesser connect success.");
cur_cxt = prefixDBAccesser.getSqlContext();
EXEC SQL CONTEXT USE :cur_cxt;
EXEC SQL DECLARE sql_cursor_prefix CURSOR FOR SELECT PrefixNum FROM T_MISC_PREFIX;
EXEC SQL OPEN sql_cursor_prefix;
#ifdef _DEBUG
LOG_AP.alert(LOG_OUT_FMT("%s",
"ntEXEC SQL DECLARE sql_cursor_prefix CURSOR FOR "
"SELECT PrefixNum FROM T_MISC_PREFIX;"));
#endif
//»ñÈ¡ËùÓмǼÐÅÏ¢
for (;;)
{
if (NOFOUND == sqlca.sqlcode)
{
#ifdef _DEBUG
LOG_AP.fatal(LOG_OUT_FMT("%s", "Record Not Found from T_MISC_PREFIX!"));
#endif
break;
}
else if (sqlca.sqlcode != 0)
{
strTmp = sqlca.sqlerrm.sqlerrmc;
strTmp = LOG_Util_String_Op::getLine(strTmp);
LOG_AP.alert(LOG_FILE_FARMAT_OUT,strTmp.c_str());
ALARM_AP(LOG_Alarm::ALERT, strTmp.c_str(),LOG_Alarm::DATABASE);
LOG_AP.error("error:%s,%d,%s", __FILE__ , __LINE__,strTmp.c_str());
return -1; //--这里需要关闭游标吗?
}
i = sqlca.sqlerrd[2];
if (i > 0)
{
//ÓÐÄÚÈÝ£¬ÉèÖñêÖ¾
bInfo = true;
}
EXEC SQL FETCH sql_cursor_prefix INTO :PrefixNum;
nFetch = sqlca.sqlerrd[2] - i;
for (i=0; i
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。