1.2.0 permalink Arrow_down_16x16

with-query-results*

clojure.contrib.sql.internal

  • (with-query-results* [sql & params :as sql-params] func)
Executes a query, then evaluates func passing in a seq of the results as
an argument. The first argument is a vector containing the (optionally
parameterized) sql query string followed by values for any parameters.

0 Examples top

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/internal.clj:178 top

(defn with-query-results*
  "Executes a query, then evaluates func passing in a seq of the results as
  an argument. The first argument is a vector containing the (optionally
  parameterized) sql query string followed by values for any parameters."
  [[sql & params :as sql-params] func]
  (when-not (vector? sql-params)
    (throw-arg "\"%s\" expected %s %s, found %s %s"
               "sql-params"
               "vector"
               "[sql param*]"
               (.getName (class sql-params))
               (pr-str sql-params)))
  (with-open [stmt (.prepareStatement (connection*) sql)]
    (doseq [[index value] (map vector (iterate inc 1) params)]
      (.setObject stmt index value))
    (with-open [rset (.executeQuery stmt)]
      (func (resultset-seq rset)))))
Vars in clojure.contrib.sql.internal/with-query-results*: class defn doseq pr-str resultset-seq vector? when-not with-open
Used in 0 other vars

Comments top

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