Let's say I had a table called, "someTable" and I want to delete the row where column1 = "data1", column2 = "data2", etc...
This is the code I have so far.
(let [db-host "asdfgh.abc.roott.net"
db-port 1234
db-name "ABCDE"]
(def db {:classname "oracle.jdbc.driver.OracleDriver" ; must be in classpath
:subprotocol "oracle:thin"
:subname (str "@" db-host ":" db-port ":" db-name)
; Any additional keys are passed to the driver
; as driver-specific properties.
:user "user"
:password "password"}
))
(sql/with-connection db
(sql/delete-rows "tableName" [{column1, data1} {column2, data2}]))
I get an error... Why?
The clojure.contrib.sql
is outdated and no longer maintained. You should use clojure.java.jdbc
instead - see Github repository, reference documentation, and community maintained documentation.
With the updated library, you don't need with-connection
, you can simply say:
(sql/delete! db :tableName ["column1 = ? and column2 = ?" data1 data2])