X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=sql%2Ffdml.lisp;fp=sql%2Ffdml.lisp;h=fcd6a3dd637e3ada63170a81486825820f794f23;hp=dc725f41e03623a0999363b758f7d5ca30fa1f98;hb=a58462f512e08c0eecf6a668a00a07ed7e858f64;hpb=8b77c3b4ba5321f4d76379d4f0663fe2717937d8 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*)