Skip site navigation (1) Skip section navigation (2)

Re: [transactions] soldier on anyway?

From: Dror Matalon <dror(at)zapatec(dot)com>
To: SF Postgres <sfpug(at)postgresql(dot)org>
Subject: Re: [transactions] soldier on anyway?
Date: 2003-11-14 04:33:39
Message-ID: 20031114043339.GP94919@rlx11.zapatec.com (view raw or flat)
Thread:
Lists: sfpug
David,

On Thu, Nov 13, 2003 at 07:33:00PM -0800, David Fetter wrote:
> Kind people,
> 
> I've got a transaction that does a few inserts, but it's OK for one
> specific one to fail in a specific way (adding a field that's already
> there).

If it's ok for one of them to fail, why do you need them to be in the
same transaction?

The easiest solution, should be to turn Autocommit on, and let the
failed insert fail independently of the other stuff.

> 
> What happens instead of what I expected is:
> 
> current transaction is aborted, queries ignored until end of transaction block
> 
> What magic do I use to get this behavior not to happen?  I'm using
> DBD::Pg on 7.3.4, and I make the connection as follows:
> 
> $dbh = DBI->connect(
>   "dbi:Pg:dbname=$dbname"
> , $user
> , $password
> , {
>     AutoCommit => 0
>   , RaiseError => 0 # I thought this part did what I want.
>   , PrintError => 1
>   }
> );
> 
> What's going on here, and how do I fix it?
> 
> Cheers,
> D
> -- 
> David Fetter david(at)fetter(dot)org http://fetter.org/
> phone: +1 510 893 6100    cell: +1 415 235 3778

-- 
Dror Matalon
Zapatec Inc 
1700 MLK Way
Berkeley, CA 94709
http://www.fastbuzz.com
http://www.zapatec.com

In response to

sfpug by date

Next:From: Josh BerkusDate: 2003-11-14 05:12:06
Subject: Yet another DBD::Pg problem
Previous:From: David FetterDate: 2003-11-14 03:48:33
Subject: Re: [transactions] soldier on anyway?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group