;; No JDBC driver lives in this sandbox, so the query runs over
;; data instead - and the parameters of an SQL query become the
;; arguments of an ordinary function
(def country-language
[{:code "RUS" :language "Russian" :percentage 86.6}
{:code "RUS" :language "Tatar" :percentage 3.2}
{:code "RUS" :language "Ukrainian" :percentage 1.3}
{:code "USA" :language "English" :percentage 86.2}])
(defn languages-of [rows code min-percent]
(->> rows
(filter #(and (= code (:code %))
(> (:percentage %) min-percent)))
(sort-by :percentage >)))
(doseq [r (languages-of country-language "RUS" 1.0)]
(println (:language r) ":" (:percentage r)))
;; with next.jdbc the arguments simply follow the ? placeholders,
;; and the driver quotes them for you:
;; (jdbc/execute! conn ["select language, percentage
;; from countrylanguage
;; where code = ? and percentage > ?"
;; "RUS" 1.0])