ado的精度要小于oracle的精度,所以在sql语句查询时要限制精度的大小,否则在读取超出精度的数值是程序将报错
下面这段去掉trunc就报错
bool checkComTime(string interval,string currentIncValue)
{
string sqlstr;
string pcode,fcode,icode;
pcode="1111";
fcode="01";
icode="download01";
sqlstr="select trunc((sysdate-nvl((select lastcomtime from tctpctrl where pointcode='"+pcode+"' and facecode='"+fcode+"' and itemcode='"+icode+"'),sysdate-365))*1440,2) diffmi,nvl((select currentincvalue from tctpctrl where pointcode='"+pcode+"' and facecode='"+fcode+"' and itemcode='"+icode+"'),0) incvalue from dual";
_RecordsetPtr rst;
string strerr="";
rst=dbo.ExecuteWithResSQL(sqlstr);
if(strerr!="")
cout<<strerr<<endl;
string strdiff;
if(rst==NULL)
cout<<"空"<<endl;
try
{
while(!rst->adoEOF)
{
strdiff=(LPSTR)(_bstr_t)(rst->GetCollect(_variant_t("diffmi")));
currentIncValue=(LPSTR)(_bstr_t)(rst->GetCollect(_variant_t("incvalue")));
cout<<strdiff<<endl;
cout<<currentIncValue<<endl;
rst->MoveNext();
}
}
catch (_com_error &e)
{
wcout<<e.Description();
}
rst->Close();
rst=NULL;
int a,b;
a=atoi(strdiff.c_str());
b=atoi(interval.c_str());
if(a>b)
{
return true;
}
else
{
return false;
}
}