X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=sql%2Ffdml.lisp;h=fcd6a3dd637e3ada63170a81486825820f794f23;hb=04ea78ee113e507c30a66cdc7a5b0984c4d5f479;hp=dc725f41e03623a0999363b758f7d5ca30fa1f98;hpb=5ed1f05543cbd24b3f2bb735f2cfc03ea85e51ec;p=clsql.git diff --git a/sql/fdml.lisp b/sql/fdml.lisp index dc725f4..fcd6a3d 100644 --- a/sql/fdml.lisp +++ b/sql/fdml.lisp @@ -1,8 +1,6 @@ ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;; ************************************************************************* ;;;; -;;;; $Id$ -;;;; ;;;; The CLSQL Functional Data Manipulation Language (FDML). ;;;; ;;;; This file is part of CLSQL. @@ -212,28 +210,28 @@ types are automatically computed for each field." (columns (gensym "COLUMNS-")) (row (gensym "ROW-")) (db (gensym "DB-"))) - `(let ((,qe ,query-expression)) + `(let ((,qe ,query-expression) + (,db ,database)) (typecase ,qe (sql-object-query - (dolist (,row (query ,qe)) + (dolist (,row (query ,qe :database ,db)) (destructuring-bind ,args ,row ,@body))) (t ;; Functional query - (let ((,db ,database)) - (multiple-value-bind (,result-set ,columns) - (database-query-result-set ,qe ,db - :full-set nil + (multiple-value-bind (,result-set ,columns) + (database-query-result-set ,qe ,db + :full-set nil :result-types ,result-types) - (when ,result-set - (unwind-protect - (do ((,row (make-list ,columns))) - ((not (database-store-next-row ,result-set ,db ,row)) - nil) - (destructuring-bind ,args ,row - ,@body)) - (database-dump-result-set ,result-set ,db)))))))))) + (when ,result-set + (unwind-protect + (do ((,row (make-list ,columns))) + ((not (database-store-next-row ,result-set ,db ,row)) + nil) + (destructuring-bind ,args ,row + ,@body)) + (database-dump-result-set ,result-set ,db))))))))) (defun map-query (output-type-spec function query-expression &key (database *default-database*)