update-or-insert does not work with oracle

Description

According to the oracle documentation

For a prepared statement batch, it is not possible to know the number of rows affected in the database by each individual statement in the batch. Therefore, all array elements have a value of -2. According to the JDBC 2.0 specification, a value of -2 indicates that the operation was successful but the number of rows affected is unknown.

As documented update-values returns (-2) which means that the (if (zero?)) check in update-or-insert-values will never return true.

Oracle does provide the number of rows updated via an the method getUpdateCount on instances of Statement.

The following change fixes this problem for oracle users, but I am not sure how it will affect other drivers.

Environment

clojure 1.3.0
clojure.java.jdbc 0.2.1
oracle 10.2.0.4.0

Activity

Show:

Sean CorfieldMay 22, 2012 at 6:17 AM

Interesting. (.getUpdateCount stmt) is a standard part of the JDBC API so it looks reasonable to see if the result of the (.executeBatch stmt) is a single sequence with a -2 value, the code could call (.getUpdateCount stmt) and return that (single) value as a sequence. It looks like that should be completely portable but it will be hard to test since none of the other DBs return -2 as far as I know and I don't have an Oracle install to test against

Completed

Details

Assignee

Reporter

Priority

Created May 21, 2012 at 4:16 PM
Updated June 1, 2016 at 6:41 PM
Resolved June 1, 2016 at 6:41 PM