;; A command changes the data instead of asking about it. There is no
;; JDBC driver here, but the change itself is a function of the rows:
;; it gives back a new value and leaves the old one alone
(def city
[{:id 1 :name "Kabul" :country-id 1}
{:id 2 :name "Qandahar" :country-id 1}
{:id 3 :name "Utrecht" :country-id 7}])
;; delete from city where country_id = 7
(def city-left (remove #(= 7 (:country-id %)) city))
(println "was" (count city) "rows, now" (count city-left))
(doseq [c city-left]
(println (:id c) (:name c)))
;; the rows we started with are still there - nothing was changed in place
(println "original still holds" (count city) "rows")
;; with next.jdbc on the classpath the same command is one call,
;; and it answers with the number of rows it touched:
;; (jdbc/execute-one! ds ["delete from city where country_id = ?" 7])