aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorscgilardi <scgilardi@gmail.com>2009-01-14 22:56:30 +0000
committerscgilardi <scgilardi@gmail.com>2009-01-14 22:56:30 +0000
commit9cbfd4ed3a438d87e0ba5903c50cab6bcf89d3ca (patch)
treeee0272b2d337651e5d55f7f10b724d4bf1a19016 /src
parent72cd5557d2159525358a08ca97eb0fea4ec3d3b4 (diff)
sql: execute batch updates within a transaction for all-or-nothing behavior, return a seq (instead of a vector) from do-commands, do-prepared so the entire set of results doesn't need to be realized unless it's interesting
Diffstat (limited to 'src')
-rw-r--r--src/clojure/contrib/sql.clj6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/clojure/contrib/sql.clj b/src/clojure/contrib/sql.clj
index 38286bba..ea9d8f0d 100644
--- a/src/clojure/contrib/sql.clj
+++ b/src/clojure/contrib/sql.clj
@@ -48,7 +48,8 @@
(with-open [stmt (.createStatement (connection))]
(doseq [cmd commands]
(.addBatch stmt cmd))
- (into [] (.executeBatch stmt))))
+ (transaction
+ (seq (.executeBatch stmt)))))
(defn do-prepared
"Executes an (optionally parameterized) SQL prepared statement on the
@@ -60,7 +61,8 @@
(doseq [[index value] (map vector (iterate inc 1) param-group)]
(.setObject stmt index value))
(.addBatch stmt))
- (into [] (.executeBatch stmt))))
+ (transaction
+ (seq (.executeBatch stmt)))))
(defn create-table
"Creates a table on the open database connection given a table name and