LispWorks User Guide and Reference Manual > 19 Common SQL > 19.9 Using MySQL > 19.9.6 Special considerations for iteration functions and macros

NextPrevUpTopContentsIndex Aborting queries which fetch many records

In the MySQL interface there is no way to abort a query when part way through it. When any of the iterations above stops before reaching its end, the underlying code retrieves all the records to the end of the query (though without converting them to Lisp objects). If the query found many records, that may be an expensive (that is, time consuming) operation.

It is possible to avoid this inefficiency by passing the argument not-inside-transaction . If not-inside-transaction is true then when a query is aborted, then LispWorks closes the database connection and reopens it, rather than retrieving all the remaining records.

(sql:map-query nil 'print 
               "select forname,surname from people"
               :get-all t
               :not-inside-transaction t)

Note that this will lose any state associated with the connection, and so not-inside-transaction should only be used with care.

LispWorks User Guide and Reference Manual - 22 Dec 2009