Created
November 3, 2011 08:31
-
-
Save drankard/1336042 to your computer and use it in GitHub Desktop.
clojure jdbc - query with cursor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def *default-fetch-size* 500) | |
(defn with-query-results-cursor [[sql & params :as sql-params] func] | |
(sql/transaction | |
(with-open [stmt (.prepareStatement (sql/connection) sql)] | |
(doseq [[index value] (map vector (iterate inc 1) params)] | |
(.setObject stmt index value)) | |
(.setFetchSize stmt *default-fetch-size*) | |
(with-open [rset (.executeQuery stmt)] | |
(func (resultset-seq rset)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment