Calculate number of rows affected by batch query in PostgreSQL

后端 未结 2 1552
[愿得一人]
[愿得一人] 2021-01-19 06:26

First of all, yes I\'ve read documentation for DO statement :) http://www.postgresql.org/docs/9.1/static/sql-do.html

So my question:

I need to execute some d

2条回答
  •  不思量自难忘°
    2021-01-19 07:09

    My solution is quite simple. In Oracle I need to use variables to calculate the sum of updated rows because command.ExecuteNonQuery() returns only the count of rows affected by the last UPDATE in the batch.

    However, npgsql returns the sum of all rows updated by all UPDATE queries. So I only need to call command.ExecuteNonQuery() and get the result without any variables. Much easier than with Oracle.

提交回复
热议问题