Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix JDBC-33 and update documentation.

  • Loading branch information...
commit 71df7bebb4dfd013d5abc15eef34482738de5389 1 parent fbdf17a
@seancorfield seancorfield authored
View
1  CHANGES.txt
@@ -1,4 +1,5 @@
Changes in 0.2.2:
+* Handle Oracle unknown row count affected [JDBC-33](http://dev.clojure.org/jira/browse/JDBC-33)
* Handle jdbc: prefix in string db-specs [JDBC-32](http://dev.clojure.org/jira/browse/JDBC-32)
* Handle empty columns in make column unique (Juergen Hoetzel) [JDBC-31](http://dev.clojure.org/jira/browse/JDBC-31)
1  README.md
@@ -89,6 +89,7 @@ Change Log
====================
* Release 0.2.2 on 2012-06-10
+ * Handle Oracle unknown row count affected [JDBC-33](http://dev.clojure.org/jira/browse/JDBC-33)
* Handle jdbc: prefix in string db-specs [JDBC-32](http://dev.clojure.org/jira/browse/JDBC-32)
* Handle empty columns in make column unique (Juergen Hoetzel) [JDBC-31](http://dev.clojure.org/jira/browse/JDBC-31)
* Release 0.2.1 on 2012-05-10
View
16 src/main/clojure/clojure/java/jdbc.clj
@@ -404,6 +404,18 @@ generated keys are returned (as a map)." }
[]
(rollback))
+(defn- execute-batch
+ "Executes a batch of SQL commands and returns a sequence of update counts.
+ (-2) indicates a single operation operating on an unknown number of rows.
+ Specifically, Oracle returns that and we must call getUpdateCount() to get
+ the actual number of rows affected. In general, operations return an array
+ of update counts, so this may not be a general solution for Oracle..."
+ [stmt]
+ (let [result (.executeBatch stmt)]
+ (if (and (= 1 (count result)) (= -2 (first result)))
+ (list (.getUpdateCount stmt))
+ (seq result))))
+
(defn do-commands
"Executes SQL commands on the open database connection."
[& commands]
@@ -411,7 +423,7 @@ generated keys are returned (as a map)." }
(doseq [^String cmd commands]
(.addBatch stmt cmd))
(transaction
- (seq (.executeBatch stmt)))))
+ (execute-batch stmt))))
(def ^{:private true
:doc "Map friendly :concurrency values to ResultSet constants."}
@@ -482,7 +494,7 @@ generated keys are returned (as a map)." }
(doseq [param-group param-groups]
(set-parameters stmt param-group)
(.addBatch stmt))
- (transaction* (fn [] (seq (.executeBatch stmt))))))))
+ (transaction* (fn [] (execute-batch stmt)))))))
(defn create-table-ddl
"Given a table name and column specs with an optional table-spec
Please sign in to comment.
Something went wrong with that request. Please try again.