X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=sql%2Ffunctional.cl;h=754ad9eac2e44f9693b71ffbb5840569374acb8a;hb=b55c36d4d3835550407db78b1baa76a0bffdc5c1;hp=d5f72ddb6e41916c2eaa7c59801e3b2273167ae0;hpb=8213ff48f5362c3d4792444c929f50bd128bd044;p=clsql.git diff --git a/sql/functional.cl b/sql/functional.cl index d5f72dd..754ad9e 100644 --- a/sql/functional.cl +++ b/sql/functional.cl @@ -8,7 +8,7 @@ ;;;; ;;;; Copyright (c) 1999-2001 Pierre R. Mai ;;;; -;;;; $Id: functional.cl,v 1.1 2002/03/23 14:04:54 kevin Exp $ +;;;; $Id: functional.cl,v 1.3 2002/05/03 20:50:18 marc.battyani Exp $ ;;;; ;;;; This file is part of CLSQL. ;;;; @@ -84,11 +84,19 @@ where) :database database)))) -(defmacro with-database ((db-var connection-spec &rest connect-args) &body body) +(defmacro with-database ((db-var connection-spec + &key (if-exists *connect-if-exists*) + (database-type *default-database-type*) + (pool nil)) + &body body) "Evaluate the body in an environment, where `db-var' is bound to the database connection given by `connection-spec' and `connect-args'. -The connection is automatically closed on exit from the body." - `(let ((,db-var (connect ,connection-spec ,@connect-args))) +If pool is t the the connection will be taken from the general pool, +if pool is a conn-pool object the connection will be taken from this pool. +The connection is automatically closed or released to the pool +on exit from the body." + `(let ((,db-var (connect ,connection-spec :pool ,pool + :database-type ,database-type :if-exists ,if-exists))) (unwind-protect (let ((,db-var ,db-var)) ,@body) (disconnect :database ,db-var))))