Re: Stopping a transaction as soon as an error occurs

From: John DeSoi <desoi(at)pgedit(dot)com>
To: Ridvan Lakas ng Bayan S(dot) Baluyos <ridvan(at)baluyos(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Stopping a transaction as soon as an error occurs
Date: 2008-07-17 11:36:23
Message-ID: 8D5DE3EA-9193-4FF8-AF46-15F8122ED745@pgedit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


On Jul 17, 2008, at 12:49 AM, Ridvan Lakas ng Bayan S. Baluyos wrote:

> I am dumping a series of data. Basically I'm migrating the tables
> from one database to another. However, I wanted the transaction to
> stop immediately as soon as the error below occurs:
>
> psql:gravy.all.schema.sql:142136: ERROR: current transaction is
> aborted, commands ignored until end of transaction block
>
> What happens is that it continues to do the transaction even if
> there's already a transaction and I'm having hard time catching it.
> I need to know which line number the error first occured so that I
> can check my dump file and do the necessary remedy.

Put this at the stop of your file to make psql stop when an error
occurs:

\set ON_ERROR_STOP 1

John DeSoi, Ph.D.

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message richard terry 2008-07-17 21:54:11 updating table where one date field is null
Previous Message Ridvan Lakas ng Bayan S. Baluyos 2008-07-17 04:49:17 Stopping a transaction as soon as an error occurs