OCCI 问题(高手帮忙!)

keke1030 2004-03-19 04:07:07
数据是8个POINT, 结果应该是8行,现在却显示了32行,为什么重复显示这么多次?请高手指教!
void restorePoint (string s)
{ string sqlStmt =
"select point_id, x, y, z from point where part_id =:x";
stmt = conn->createStatement (sqlStmt);
stmt->setString (1, s);
ResultSet *rset = stmt->executeQuery ();

int point_id[5];
ub2 point_id_len[5];
rset->setDataBuffer(1, &point_id, OCCIINT, (ub2)
sizeof(point_id[0]), &point_id_len[0]);

double coorx[5];
ub2 coorx_len[5];
rset->setDataBuffer(2, &coorx, OCCIFLOAT, (ub2)
sizeof(coorx[0]), &coorx_len[0]);

double coory[5];
ub2 coory_len[5];
rset->setDataBuffer(3, &coory, OCCIFLOAT, (ub2)
sizeof(coory[0]), &coory_len[0]);
double coorz[5];
ub2 coorz_len[5];
rset->setDataBuffer(4, &coorz, OCCIFLOAT, (ub2)
sizeof(coorz[0]), &coorz_len[0]);

cout << "point_id coorx coory coorz " << endl;
cout << "======== ===== ===== ===== " << endl;

int rowCounter = 0;
try {
while (rset->next(5)) {
for (int i = 0; i < 5; i++)
cout<<point_id[i]<< " "<<coorx[i]<< " " <<coory[i]<< " " <<coorz[i]<<endl;
rowCounter += 5;
}
int remainingRows = rset->getNumArrayRows() - rowCounter;
for (int i = 0; i < remainingRows; i++)
cout<<point_id[i]<< " "<<coorx[i]<< " " <<coory[i]<< " " <<coorz[i]<<endl;
}
catch(SQLException ex) {
cout << "Exception thrown for next() method" << endl;
cout << ex.getErrorCode() << endl;
}
cout << "Restore - Success" << endl;
stmt->closeResultSet (rset);
conn->terminateStatement (stmt);
}
...全文
62 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
hushuangyang 2004-03-27
  • 打赏
  • 举报
回复
while (rset->next(5)) {
for (int i = 0; i < 5; i++)
cout<<point_id[i]<< " "<<coorx[i]<< " " <<coory[i]<< " " <<coorz[i]<<endl;
rowCounter += 5;
}
这里两个循环重复了。
dou1204 2004-03-22
  • 打赏
  • 举报
回复
up
keke1030 2004-03-21
  • 打赏
  • 举报
回复
高手?
keke1030 2004-03-21
  • 打赏
  • 举报
回复
CSDN怎么搞的?
keke1030 2004-03-19
  • 打赏
  • 举报
回复
没人帮忙?

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧