English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Re: [Caml-list] PostgreSQL-OCaml 1.0.1
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-01-30 (13:22)
From: Richard Jones <rich@a...>
Subject: Re: [Caml-list] PostgreSQL-OCaml 1.0.1
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

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 *)


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.


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