In Amazon Redshift, I'm using the following query to capture the number of rows inserted by the last query:
SELECT SUM(rows) FROM stl_insert WHERE query = pg_last_query_id();
It seems that this approach doesn't work when I insert into a table that contains an IDENTITY column, because Redshift also runs this query: SELECT * FROM stv_identity_highwater and uses this query's id for pg_last_query_id().
Is there another way to capture the number of rows inserted in this scenario?