If you do them all in one session and surround them with BEGIN and COMMIT
then it'll become an all or nothing affair.
On Mon, Feb 24, 2003 at 06:29:27PM -0800, Drew Wilson wrote:
> I'm trying to script some updates to system tables, and I can't figure
> out how to detect an error condition in the SQL sent to psql.
>
> Is there anyway to test for errors returned by psql?
>
> For example:
> echo "select foo from pg_database" | psql -U admin myDB || echo
> "failed" && echo "success"
>
> This doesn't work. Neither "failed" nor "success" are echoed.
> Only 'ERROR: Attribute "foo" not found' is displayed on console.
>
>
> Alternatively, is there a way to do this as a single transaction, that
> will rollback if any statement fails? (Without installing PL/pgSQL,
> that is.)
>
>
> TIA,
>
> Drew
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> Support bacteria! They're the only culture some people have.