psql script error handling

From: James Neff <jneff(at)tethyshealth(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: psql script error handling
Date: 2006-12-30 00:21:12
Message-ID: 4595B0F8.7060508@tethyshealth.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have an sql script that I am trying to execute in psql client on the
database itself. The script is just a bunch (hundreds of thousands) of
INSERT statements.

I don't know how, but I seem to have bad characters throughout my file
and when I run the script it will of course error out complaining about
the invalid character. I figure out how many insert statements were
successful and use sed to chop of those statements from the sql script
file. I then use VI and delete out the bad character and re-run the
script.

There's got to be a better way to do this. Is there a way in a psql
script to try to execute the INSERT statement and if theres a problem to
dump it to a log file and go on with the others?

Thanks in advance,
James

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ben 2006-12-30 00:31:21 Re: Geographical redundancy
Previous Message Alvaro Herrera 2006-12-29 23:25:11 Re: Autovacuum Improvements