Re: How to check for successfull inserts - Mailing list pgsql-general

From Arguile
Subject Re: How to check for successfull inserts
Date
Msg-id LLENKEMIODLDJNHBEFBOMEIPEFAA.arguile@lucentstudios.com
Whole thread Raw
In response to How to check for successfull inserts  (Francisco Reyes <lists@natserv.com>)
Responses Re: How to check for successfull inserts
Re: How to check for successfull inserts
List pgsql-general
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.



pgsql-general by date:

Previous
From: Thomas Lockhart
Date:
Subject: Re: decimal(5) vs int8. Which more efficient.
Next
From: "Arguile"
Date:
Subject: Re: How to check for successfull inserts