with-query-results

clojure.contrib.sql

  • (with-query-results results sql-params & body)
Executes a query, then evaluates body with results bound to a seq of the
results. sql-params is a vector containing a string providing
the (optionally parameterized) SQL query followed by values for any
parameters.

1 Example top

  • (with-connection db
      (do-commands "create table person (name varchar(255))")
      (insert-values :person [:name] ["bill"] ["joey"])
    
      (with-query-results results ["select name from person"]
        (doall results)))
    
    ;; => ({:name "bill"} {:name "joey"})
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:195 top

(defmacro with-query-results
  "Executes a query, then evaluates body with results bound to a seq of the
  results. sql-params is a vector containing a string providing
  the (optionally parameterized) SQL query followed by values for any
  parameters."
  [results sql-params & body]
  `(with-query-results* ~sql-params (fn [~results] ~@body)))
Vars in clojure.contrib.sql/with-query-results: defmacro apply concat fn list seq vector
Used in 0 other vars

Comments top

No comments for with-query-results. Log in to add a comment.