当前位置: 代码迷 >> Informix >> informix游标没有报错却查不到数据记录
  详细解决方案

informix游标没有报错却查不到数据记录

热度:9564   发布时间:2013-02-26 00:00:00.0
informix游标没报错却查不到数据记录
我用游标查询记录集查不到数据,也没有报错,
EXEC SQL select object_class into :object_class from object_class where object_type=:object_type;
sprintf(strsql,"select int_id,nvl(city_id,0),nvl(parent_int_id,0),object_rdn,nvl(manufacturer,0),version from objects where object_class=%d",object_class);
EXEC SQL PREPARE slct FROM :strsql;
EXEC SQL DECLARE cur_a CURSOR FOR slct;
EXEC SQL OPEN cur_a;
while(1)
{
EXEC SQL FETCH cur_a INTO :int_id,:city_id,:parent_int_id,:object_rdn,:manufacturer,:version;
if(sqlca.sqlcode=100)
{
break;
}
}
但是我用单记录查询时是可以查到记录的
EXEC SQL select first 1 int_id,nvl(city_id,0),nvl(parent_int_id,0),object_rdn,nvl(manufacturer,0),version into :int_id,:city_id,:parent_int_id,:object_rdn,:manufacturer,:version from objects where object_class=:object_class;

这种情况是什么原因,怎么解决呢?我新手,高手们指导指导啊

------解决方案--------------------------------------------------------
动态语句里object_class是啥类型的变量,如果是字符串的要加''才行
------解决方案--------------------------------------------------------
EXEC SQL select object_class into :object_class from object_class where object_type=:object_type; 
sprintf(strsql,"select int_id,nvl(city_id,0),nvl(parent_int_id,0),object_rdn,nvl(manufacturer,0),version from objects where object_class=‘%d’ ",object_class);
------解决方案--------------------------------------------------------
sqlca.sqlcode报得是啥错呢?
------解决方案--------------------------------------------------------
那只能是数据不符合,程序上没发现有啥问题,追踪索引看看吧
  相关解决方案