Re: How to check for successfull inserts

From: "Arguile" <arguile(at)lucentstudios(dot)com>
To: "pgsql General List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to check for successfull inserts
Date: 2002-03-09 05:41:49
Message-ID: LLENKEMIODLDJNHBEFBOMEIPEFAA.arguile@lucentstudios.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Arguile 2002-03-09 06:09:42 Re: How to check for successfull inserts
Previous Message Thomas Lockhart 2002-03-09 03:52:17 Re: decimal(5) vs int8. Which more efficient.