Guest User

Untitled

a guest
Apr 26th, 2013
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (ns db-test.core
  2.   (:require [clojure.java.jdbc :as j])
  3.   (use [korma.db])
  4.   (use [korma.core])
  5.   (:gen-class))
  6.  
  7. (defn setup-connection []
  8.   (def oracle-db {:classname "oracle.jdbc.odbc.OracleDriver"
  9.                 :subprotocol "oracle"
  10.                 :subname "thin:@//remotehost:1521/derpina1"
  11.                 :user "user"
  12.                 :password "pass" })
  13.   (j/get-connection oracle-db)
  14.   (default-connection oracle-db)
  15.   (defentity PGDV_REPAIR))
  16.  
  17. (def records (select PGDV_REPAIR (fields :PROD_ID :RETAIL :GOTO_RETAIL) (where {:REPAIR_ID [= 2 5]})))
  18.  
  19. (defn alter-goto-repair
  20.   []
  21.   (doseq [{retail :RETAIL
  22.            prod-id :PROD_ID
  23.            :as row} records]
  24.     (update PGDV_REPAIR (set-fields {:GOTO_RETAIL (+ (rand-int 100)
  25.                                                      retail)})
  26.             (where {:REPAIR_ID [= 2 5]})
  27.             (where {:PROD_ID prod-id}))))
  28.  
  29.  
  30. (defn -main
  31.   "This function is where all the functions in this namespace come together"
  32.   [& args]
  33.     (setup-connection)
  34.     (alter-goto-repair))
Advertisement
Add Comment
Please, Sign In to add comment