Hello, if I want to run some sql code in a transaction, I can do
this (where clojure.java.jdbc is referred to as j):

(j/db-transaction
 [conn dbspec]
  use conn here

But if I have a function I want to call from this transaction, say to
do a query, then I need to pass in the connection to that function:

(defn query [conn]
  do query on conn...)

(j/db-transaction
 [db dbspec]
  (query conn))

I am trying to decide whether I like passing in the connection to
query, or whether I would rather use a binding like so:

(def ^:dynamic *conn*)

(defn query []
  do query on *conn*...)

(j/db-transaction
 [conn dbspec]
  (binding [*conn* conn]
   (query)))

Looking at the jdbc docs, I notice that this style used to be directly
supported but is now deprecated. Does that mean it's a bad idea to
re-implement on top of the supported API, as my example would? Can
someone explain the tradeoffs involved?

Thanks,
Lyn Headley

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to