Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 793DB9FA9BD for ; Fri, 2 Feb 2007 11:09:16 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 35643-06 for ; Fri, 2 Feb 2007 11:09:06 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id 3AA0C9FA22A for ; Fri, 2 Feb 2007 11:09:12 -0400 (AST) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.8/8.13.8) with ESMTP id l12F94Vt099279 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 2 Feb 2007 08:09:07 -0700 (MST) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.8/8.13.8) with ESMTP id l12F949P011355; Fri, 2 Feb 2007 08:09:04 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.8/8.13.8/Submit) id l12F94jp011354; Fri, 2 Feb 2007 08:09:04 -0700 (MST) (envelope-from mfuhr) Date: Fri, 2 Feb 2007 08:09:04 -0700 From: Michael Fuhr To: Sandeep Khandelwal Cc: pgsql-interfaces@postgresql.org Subject: Re: PQputCopyData and Rollback/Commit Message-ID: <20070202150903.GA11313@winnie.fuhr.org> References: <301290.97125.qm@web33313.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <301290.97125.qm@web33313.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/2 X-Sequence-Number: 6422 On Thu, Feb 01, 2007 at 10:32:21PM -0800, Sandeep Khandelwal wrote: > I am using PQputCopyData function to send data to server one row at > a time. When I am done with the data then I call PQputCopyEnd. > > I want to do rollback when any error occurs. Please help me how > to achieve rollback using these functions. As the documentation for PQputCopyEnd() says, you can pass a non-NULL second argument to force the copy to fail. You could also use PQexec() to execute a BEGIN before the copy and a COMMIT or ROLLBACK after the copy. -- Michael Fuhr