From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | Francisco Reyes <lists(at)natserv(dot)com> |
Cc: | pgsql General List <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How to check for successfull inserts |
Date: | 2002-03-08 23:28:06 |
Message-ID: | 20020309102806.B10827@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)svana(dot)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?
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2002-03-09 00:24:45 | Re: Is vacuum full lock like old's vacuum's lock? |
Previous Message | Martijn van Oosterhout | 2002-03-08 23:04:26 | Re: Is vacuum full lock like old's vacuum's lock? |