Thread: Retrieve number of rows from COPY command inside a plpgsql function

Retrieve number of rows from COPY command inside a plpgsql function

From
Erwin Brandstetter
Date:
Aloha!

I am trying to retrieve the number of rows copied by a COPY command
inside a plpgsql function.

The docs tell me, that the "command tag" holds this information. But
how to access the command tag from within a plpgsql function?
http://www.postgresql.org/docs/9.0/interactive/sql-copy.html

I am COPYing the huge result of a complex SQL query to a file and
would like to output the number of rows. I could write to a temp table
and use
GET DIAGNOSTICS integer_var = ROW_COUNT;
and COPY from there. But that takes twice as long. GET DIAGNOSTICS
does not currently work for COPY ..

Am I missing something?

TIA
Erwin Brandstetter