From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id OAA21556; Fri, 30 Jan 2004 14:22:29 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id OAA21466 for ; Fri, 30 Jan 2004 14:22:28 +0100 (MET) Received: from aomori.annexia.org (annexia.force9.co.uk [212.56.101.183]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id i0UDMRv05842 for ; Fri, 30 Jan 2004 14:22:27 +0100 (MET) Received: from rich by aomori.annexia.org with local (Exim 3.36 #1 (Debian)) id 1AmYbL-0008Q8-00; Fri, 30 Jan 2004 13:22:27 +0000 Date: Fri, 30 Jan 2004 13:22:26 +0000 To: Benjamin Geer Cc: caml-list@inria.fr Subject: Re: [Caml-list] PostgreSQL-OCaml 1.0.1 Message-ID: <20040130132226.GA32353@redhat.com> References: <20040130120206.GA28458@redhat.com> <401A4AD9.2060509@socialtools.net> <20040130122311.GA29288@redhat.com> <401A548B.2090603@socialtools.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <401A548B.2090603@socialtools.net> User-Agent: Mutt/1.5.4i From: Richard Jones X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 1.0.1:01 2004:99 dbh:99 dbh:99 rolls:99 dbi:99 ltd:98 behaviour:01 exits:01 checking:01 wrote:03 wrote:03 let:04 exceptions:04 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, Jan 30, 2004 at 12:56:43PM +0000, Benjamin Geer wrote: > Richard Jones wrote: > >It throws Sql_error when it can determine an error. > > Another thing I forgot to bring up about error handling. If an error > occurs, you generally want to roll back the transaction. If you're You might want to have a look at the code to see if it does what you want. In practice, writing mainly CGI scripts and standalone scripts as we do, this is never a problem for us. Our code is structured like this: let dbh = (* open connection, or get connection from pool *) (* do work with the connection, never checking for any exceptions *) dbh#commit In the case of a standalone script, the script dies (exits) when an error occurs, printing the SQL error message. The database then automatically rolls back the connection. This is just the behaviour of PostgreSQL - if a connection is closed in the middle of a transaction then the database gets rolled back. In the case of CGI scripts, the Dbi Pool code automatically performs a dbh#rollback just before taking back a connection and placing it back into the pool. So if an error did occur before the commit, then the database gets rolled back. Rich. -- Richard Jones. http://www.annexia.org/ http://www.j-london.com/ Merjis Ltd. http://www.merjis.com/ - improving website return on investment http://www.YouUnlimited.co.uk/ - management courses ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners