Hello,
Here is some code to show what I'm doing. The table some_data is "create table some_data (id integer, clob_data clob)" which has clobs of various lengths.
(defn add? [m k func newkey]
(if (m k)
(conj m [newkey (func (m k))])
m))
(defn clob-to-string [clob]
"Turn an Oracle Clob into a String"
(with-open [rdr (java.io.BufferedReader. (.getCharacterStream clob))]
(apply str (line-seq rdr))))
(defentity some_data
(entity-fields :id :clob_data)
(transform #(-> %
(add? :clob_data clob-to-string :clob_data_str))))
(select some_data)
; SQLRecoverableException Closed Connection oracle.sql.CLOB.getDBAccess (CLOB.java:1714)
(transaction (select some_data))
; SQLRecoverableException Closed Connection oracle.sql.CLOB.getDBAccess (CLOB.java:1714)
I am able to read clobs with clojure.java.jdbc
(j/query db/orcldap ["select id, clob_data from some_data"]
:row-fn #(add? % :clob_data clob-to-string :clob_data_str))
This is with Clojure 1.6, korma 0.3.2, java.jdbc 0.3.6, Oracle 11.2.0.3.0, and jdbc 12.1.0.1.0.
It seems that the transaction the clobs are read with has closed before the transform function is called.
I'm hoping I'm just doing something wrong and can get Korma to work as I really like using it in the REPL.
Thanks.