Using postgres 9.6.
I am attempting to write a function that will delete records and return to the application developer the number of rows that were deleted. I have some the following demo but I keep running into a syntax issue.
BEGIN;
DELETE FROM it.animals WHERE id <5
RETURNING COUNT(id);
ROLLBACK;
[2020-03-12 09:14:11] [42803] ERROR: aggregate functions are not allowed in RETURNING