首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Informix >

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

2012-07-30 
informix游标没报错却查不到数据记录我用游标查询记录集查不到数据,也没有报错,EXEC SQL select object_cl

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报得是啥错呢?
[解决办法]
那只能是数据不符合,程序上没发现有啥问题,追踪索引看看吧

热点排行