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

解决方案 »

  1.   

    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: 0mysql> 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 函数返回的值相同。
      

  2.   

    用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