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.
--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to