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

From Martijn van Oosterhout
Subject Re: How to check for successfull inserts
Date
Msg-id 20020309102806.B10827@svana.org
Whole thread Raw
In response to How to check for successfull inserts  (Francisco Reyes <lists@natserv.com>)
List pgsql-general
On Fri, Mar 08, 2002 at 05:33:25PM -0500, Francisco Reyes wrote:
> 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.

Note, this is basically completely whacky, but it does work. Hopefully
someone has a better idea!

select case when (select count(*) from table) = 0
            then date_part('day',now())/0
            else 1 end;

Add that in, then when the table has no rows, the transaction will die with
a divide by zero and everything will be rolled back.

There probably is a function somewhere that you can call like
abort_transaction("error message") but I don't know what it is.

HTH,
--
Martijn van Oosterhout <kleptog@svana.org>
http://svana.org/kleptog/
> If the company that invents a cure for AIDS is expected to make their
> money back in 17 years, why can't we ask the same of the company that
> markets big-titted lip-syncing chicks and goddamn cartoon mice?

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Is vacuum full lock like old's vacuum's lock?
Next
From: Tom Lane
Date:
Subject: Re: Is vacuum full lock like old's vacuum's lock?