Question

How do I get started?

Was it helpful?

Solution

I have found the easiest way to achieve this by using Clojure. Here is the example code:


(ns example
  (:require [clojure.contrib.sql :as sql])
  (:import  [java.sql Types]))

(def devdb {:classname "oracle.jdbc.driver.OracleDriver" :subprotocol "oracle" :subname "thin:username/password@localhost:1509:devdb" :create true})

(defn exec-ora-stored-proc [input-param db callback] (sql/with-connection db (with-open [stmt (.prepareCall (sql/connection) "{call some_schema.some_package.test_proc(?, ?, ?)}")] (doto stmt (.setInt 1 input-param) (.registerOutParameter 2 Types/INTEGER) (.registerOutParameter 3 oracle.jdbc.driver.OracleTypes/CURSOR) (.execute)) (callback (. stmt getInt 2) (. stmt getObject 3)))))

(exec-ora-stored-proc 123 ;;input param value devdb (fn [err-code res-cursor] (println (str "ret_code: " err-code)) ;; prints returned refcursor rows (let [resultset (resultset-seq res-cursor)] (doseq [rec resultset] (println rec)))))

OTHER TIPS

You'll need an interface to the Oracle SQL database. As Bob pointed out, Allegro CL has such an interface.

GNU CLISP apparently comes with an interface to the database as well.

The most straightforward way to do Oracle stuff from your Common Lisp program is to use CLSQL. There are plenty of other packages for doing stuff with databases from Common Lisp. Have a look at Cliki's database page

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top