Re: Skipping errors when running scripts

From: John DeSoi <desoi(at)pgedit(dot)com>
To: John Gardner <john(dot)gardner(at)tagish(dot)co(dot)uk>
Cc: pgsql-novice Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Skipping errors when running scripts
Date: 2009-07-09 13:24:53
Message-ID: 18B87009-DA8C-43AB-9E68-F6A14D834037@pgedit.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


On Jul 9, 2009, at 6:26 AM, John Gardner wrote:

> I'm porting a couple of databases over from SQL Server to Oracle.
> This
> question isn't so much about the plsql syntax it's about the way
> PostgreSQL runs scripts and stops every time it occurs an error.
>
> For instance, when I run a script in SQL Server, and it comes across a
> problem e.g. It tries to drop a table that doesn't exist, it will
> notify
> me of the error, and then continue on. With PostgreSQL (or at least
> running scripts in pgAdmin III) the script runs, comes across the
> error
> and then rolls back to before the script was run.
>
> I know why it does that, so your system is always in a clean state
> upon
> an error, but can you change the behaviour so that when comes across
> an
> error it notifies me and then continues instead of stopping?
>
> We're running 8.2 by the way.

If you run your script with psql instead of pgAdmin III, the default
is to not stop. If you want your script to stop on errors with psql,
you can put this at the top of the script:

\set ON_ERROR_STOP 1

John DeSoi, Ph.D.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2009-07-09 13:58:23 Re: Skipping errors when running scripts
Previous Message John Gardner 2009-07-09 10:26:33 Skipping errors when running scripts