Deletes rows from a table. where-params is a vector containing a string
providing the (optionally parameterized) selection criteria followed by
values for any parameters.
;;
;; the first line allows us to say sql/with-connection instead of
;; clojure.contrib.sql/with-connection
;;
(require '[clojure.contrib.sql :as sql])
(defn delete-blog
"Deletes a blog entry given the id"
[id]
(sql/with-connection db
(sql/delete-rows :blogs ["id=?" id])))
;; From http://en.wikibooks.org/wiki/Clojure_Programming/Examples/JDBC_Examples#DELETE
(defn delete-rows
"Deletes rows from a table. where-params is a vector containing a string
providing the (optionally parameterized) selection criteria followed by
values for any parameters."
[table where-params]
(let [[where & params] where-params]
(do-prepared
(format "DELETE FROM %s WHERE %s"
(as-str table) where)
params)))
Comments top
No comments for delete-rows. Log in to add a comment.