免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6307 | 回复: 4
打印 上一主题 下一主题

请问db2 c语言接口cli用什么函数可以查看刚刚执行的select语句返回记录的条数阿 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-02-28 17:59 |只看该作者 |倒序浏览
50可用积分
我看有函数SqlDescribeCol,可没有SQLdescribeRow,请问怎么才能知道我刚刚执行的select一词返回记录的条数阿,我好分配内存阿

论坛徽章:
0
2 [报告]
发表于 2008-02-28 18:11 |只看该作者
原帖由 picobsd 于 2008-2-28 17:59 发表
我看有函数SqlDescribeCol,可没有SQLdescribeRow,请问怎么才能知道我刚刚执行的select一词返回记录的条数阿,我好分配内存阿


我记得 odbc 中有这个 SQLRowCount

我看DB2 的 CLI 和 ODBC 接口函数差不多,你试试

论坛徽章:
0
3 [报告]
发表于 2008-02-29 09:49 |只看该作者
恐怕不行吧,看说明

SQLRowCount()returns the number of rows in a table that were affected by an UPDATE,INSERT,DELETE,or MERGE statement  executed against the table,or a view based on the table.SQLExecute()or SQLExecDirect() must be calledbefore calling this function.

[ 本帖最后由 picobsd 于 2008-2-29 09:51 编辑 ]

论坛徽章:
0
4 [报告]
发表于 2008-03-03 15:17 |只看该作者
select  count(*) from tablename

论坛徽章:
0
5 [报告]
发表于 2008-03-04 17:11 |只看该作者
我查看了一下,cli调用只能得到update insert delete  SQL影响的的行数,select好像不行,不过在cli调用里面,select都是用显示游标的形式查看数据的,所以你直接在遍历数据的循环里面加个计数器吧:

原文:
  1. SQLRowCount() returns the number of rows in a table that were affected by an
  2. UPDATE, INSERT, or DELETE statement executed against the table, or a view
  3. based on the table.

  4. SQLRETURN SQLRowCount (
  5.                 SQLHSTMT StatementHandle, /* hstmt */
  6.                 SQLINTEGER *RowCountPtr); /* pcrow */
复制代码
  1. SQLAllocHandle (SQL_HANDLE_STMT, hdbc, &hstmtparent);
  2. cliRC = SQLExecDirect(hstmtparent, (SQLCHAR *)"delete * FROM ORG", SQL_NTS);
  3. SQLRowCount (hstmtparent, &numRows);
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP