Skip to content

Instantly share code, notes, and snippets.

View lancepantz's full-sized avatar

lance bradley lancepantz

  • bird
  • los angeles, ca
View GitHub Profile
anonymous
anonymous / metadata generated keys
Created August 10, 2010 04:20
(defn do-prepared-with-generated-keys
"Executes an (optionally parameterized) SQL prepared statement on the
open database connection. Each param-group is a seq of values for all of
the parameters. #THIS MONKEY PATCH INCLUDES METADATA#"
[sql & param-groups]
(with-open [stmt (.prepareStatement (connection) sql)]
(doseq [param-group param-groups]
(doseq [[index value] (map vector (iterate inc 1) param-group)]
(.setObject stmt index value))
(.addBatch stmt))