How can I get the number of records affected by a stored procedure?

前端 未结 6 1989
轮回少年
轮回少年 2020-12-04 20:32

For INSERT, UPDATE and DELETE SQL statements executed directly against the database, most database providers return the count of rows

6条回答
  •  情歌与酒
    2020-12-04 21:28

    Register an out parameter for the stored procedure, and set the value based on @@ROWCOUNT if using SQL Server. Use SQL%ROWCOUNT if you are using Oracle.

    Mind that if you have multiple INSERT/UPDATE/DELETE, you'll need a variable to store the result from @@ROWCOUNT for each operation.

提交回复
热议问题