Skip to content

Instantly share code, notes, and snippets.

@frankvilhelmsen
Last active December 16, 2015 02:29
Show Gist options
  • Save frankvilhelmsen/5362434 to your computer and use it in GitHub Desktop.
Save frankvilhelmsen/5362434 to your computer and use it in GitHub Desktop.
call oracle stored procedure returning-cursor from clojure
(ns package.classname
(:require [clojure.xml :as xml]
[clojure.java.jdbc :as jdbc]))
(:import java.sql.Types)
(def db {:classname "oracle.jdbc.driver.OracleDriver"
: ....
:password (System/getenv "password")})
(jdbc/with-connection db
(with-open [stmt (.prepareCall (jdbc/connection) "{ call PACKAGE.PROCEDURE(?, ?) }")]
(doto stmt
(.registerOutParameter 1 java.sql.Types/INTEGER)
(.registerOutParameter 2 oracle.jdbc.OracleTypes/CURSOR)
(.execute))
(vec (resultset-seq (. stmt getObject 2)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment