Par exemple en utilisant RETURNING
:
DROP TABLE IF EXISTS t;
CREATE TABLE t(i INT);
INSERT INTO t(i) VALUES (1),(2),(3);
WITH cte AS
(
UPDATE t
SET i = i * 10
WHERE i > 1
RETURNING *
)
SELECT COUNT(*) AS num_of_rows_updated
FROM cte;