delete-rows

clojure.contrib.sql

  • (delete-rows table where-params)
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.

1 Example top

  • ;;
    ;; 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
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/sql.clj:157 top

(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)))
Vars in clojure.contrib.sql/delete-rows: do-prepared defn format let
Used in 0 other vars

Comments top

No comments for delete-rows. Log in to add a comment.