On Jan 2, 2009, at 2:21 AM, budu wrote:
Hi, I was experimenting with clojure-contrib's sql features and found
that there wasn't any update-values function. I've written my own and
I'm sharing it here:
(defn update-values [table where column-names & values]
"Update columns of a table with values. columns-names is a vector of
column names (strings or keywords) and the rest of arguments are the
values for those columns."
(let [columns (map #(str (the-str %) " = ?") column-names)
template (if (seq column-names)
(apply str (interpose "," columns))
"")]
(apply do-prepared
(format "update %s set %s where %s"
(the-str table) template where)
[values])))
It only send one set of values to do-prepared because of the where
clause that would have to change according to each sets. I'm ready for
your commentaries and/or suggestions.
Hi budu,I'd like to include something like this in clojure.contrib.sql. That will go smoothest if I can base it directly on what you've written and that's only possible if you send in a contributor agreement. Would you please send one in?
Please see http://clojure.org/contributing for more info. Thanks, --Steve
smime.p7s
Description: S/MIME cryptographic signature
