Skip to content

Instantly share code, notes, and snippets.

@gdeer81
Last active July 11, 2018 16:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gdeer81/5470227 to your computer and use it in GitHub Desktop.
Save gdeer81/5470227 to your computer and use it in GitHub Desktop.
an example of updating an oracle database from clojure the server, user names, and passwords have been changed to protect the innocent
(ns db-test.core
(:require [clojure.java.jdbc :as j])
(use [korma.db])
(use [korma.core])
(:gen-class))
(defn setup-connection []
(def oracle-db {:classname "oracle.jdbc.odbc.OracleDriver"
:subprotocol "oracle"
:subname "thin:@//remotehost:1521/derpina1"
:user "user"
:password "pass" })
(j/get-connection oracle-db)
(default-connection oracle-db)
(defentity PGDV_REPAIR))
(def records (select PGDV_REPAIR (fields :PROD_ID :RETAIL :GOTO_RETAIL) (where {:REPAIR_ID [in [2 5]]})))
(defn alter-goto-repair []
(doseq [row records]
(update PGDV_REPAIR
(set-fields {:GOTO_RETAIL (+ (rand-int 100) (:RETAIL row))})
(where {:REPAIR_ID [in [2 5]]})
(where {:PROD_ID (:PROD_ID row)}))))
(defn -main
"This function is where all the functions in this namespace come together"
[& args]
(setup-connection)
(alter-goto-repair))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment