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.
(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"})
(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)))
Comments top
No comments for with-query-results. Log in to add a comment.