0

Is it possible to get numbers of rows inserted into a table by a INSERT INTO statement? Preferably by using something like RETURNING in the SQL statement. Alternatively, by using PLPGSQL?

Thomas
  • 962
  • 2
  • 9
  • 18
  • Closed as dup. If you still prefer to use `returning`, simply `count()` the affected rows. – Denis de Bernardy Dec 07 '14 at 23:29
  • Thanks for your comment, but when I try the following syntax INSERT INTO ... RETURNING COUNT(*) I get the following error: aggregate functions are not allowed in RETURNING – Thomas Dec 08 '14 at 06:36
  • I'm pretty sure you can work around that using a CTE: `with rows as (insert ... returning ...) select count(*) from rows`. The better approach, though, is to get the diagnostics directly, as suggested in the answers from the other post. – Denis de Bernardy Dec 08 '14 at 09:54

0 Answers0