mysql 如何存储过程返回记录的更新条数

babygehui 2009-01-21 05:30:36
mysql 如何存储过程返回记录的更新条数
...全文
821 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
fengzhiquxiang1 2009-01-28
  • 打赏
  • 举报
回复
mark
wwwwb 2009-01-22
  • 打赏
  • 举报
回复
用ROW_COUNT()就可以了
ROW_COUNT() returns the number of rows updated, inserted, or deleted by the preceding statement.
用如下方法可以直接得到影响的行数:
sql="update table1 set field1='good'"
set conn=server.createobject("adodb.connection")
conn.open dsn
conn.execute sql,lngrecs
conn.close:set conn=nothing
response.write lngrecs
ACMAIN_CHM 2009-01-21
  • 打赏
  • 举报
回复
google
搜索 mysql update row affected store procedure
看到 ROW_COUNT() ,再查MySQL 5.1手册 如下,其实问题你自己也可以简单解决。


ROW_COUNT()

ROW_COUNT() returns the number of rows updated, inserted, or deleted by the preceding statement. This is the same as the row count that the mysql client displays and the value from the mysql_affected_rows() C API function.

mysql> INSERT INTO t VALUES(1),(2),(3);
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0

mysql> SELECT ROW_COUNT();
+-------------+
| ROW_COUNT() |
+-------------+
| 3 |
+-------------+
1 row in set (0.00 sec)

mysql> DELETE FROM t WHERE i IN(1,2);
Query OK, 2 rows affected (0.00 sec)

mysql> SELECT ROW_COUNT();
+-------------+
| ROW_COUNT() |
+-------------+
| 2 |
+-------------+
1 row in set (0.00 sec)



ROW_COUNT()
ROW_COUNT()返回被前面语句升级的、插入的或删除的行数。 这个行数和 mysql 客户端显示的行数及 mysql_affected_rows() C API 函数返回的值相同。


57,064

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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