Francisco Reyes writes:
>
> I have a script of the form
> begin work
> delete
> copy from ...
> commit work
>
> Basically in a couple of ocassions the file been read from the copy
> command was empty. How could I check for this from a pgsql script?
>
> I tried look at PL-SQL manuals, but didn't find anything which would seem
> to help in solving this problem.
>
Normally I'd point you to this,
http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/plpgsql-statemen
ts.html#PLPGSQL-STATEMENTS-DIAGNOSTICS
but I just checked and COPY FROM doesn't return that count (unlike INSERT).
It would be nice if it did but that doesn't help you much.
The only other thing I can think of off the top of my head is to count(*)
the table in question before and after and return the difference. As you're
within a transaction it will be accurate, if rather unwieldy.