Retrieve number of rows from COPY command inside a plpgsql function

From: Erwin Brandstetter <brsaweda(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Retrieve number of rows from COPY command inside a plpgsql function
Date: 2011-08-18 20:14:22
Message-ID: 8753f741-0462-487d-b5e3-9ded4aabe845@y4g2000vbx.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

Browse pgsql-general by date

  From Date Subject
Next Message Dmitry Koterov 2011-08-18 20:23:25 Re: Dump a database excluding one table DATA?
Previous Message Adrian Klaver 2011-08-18 20:04:22 Re: Dump a database excluding one table DATA?