Steve Thanks, this works as described, I am going to look into what it would take to do a call to a parameterized stored proc. BTW, I did get a parameterized SP working, here is my sample code:
(defn sp-test "test of stored procedures" [min max] (sql/with-connection db (sql/with-query-results res ["EXEC ProdIVR.dbo.SelectByGradeRange @lowerRange=?, @upperRange=?" min max] (doseq [rec res] (println rec))))) This works, and is nice, but does not take full advantage of SQL Server's stored procedure cache, the way a true JDBC call to a parameterized SP would work, with a PreparedStatement object. I am looking into that, to see how I could spec out a "with-call-results" requirements for addition to clojure-contrib.sql. Once again, thanks for your assistance, attention, and efforts. Brian On Jan 30, 11:12 am, "Stephen C. Gilardi" <squee...@mac.com> wrote: > Hi Brian, > > On Jan 29, 2009, at 11:03 AM, BrianS wrote: > > > Now that I am beginning to really investigate this cool part of the > > clojure-contrib library with SQL Server, I have hit the point where I > > would like to call parameterized stored procedures, which is why you > > said you changed the SQL command from a string to a vector. > > The change to a vector was for parameterized queries (using > PreparedStatement, prepareStatement), not for parameterized calls to > stored procedures (using CallableStatement, prepareCall). Here's an > example of the former from clojure.contrib.sql.test: > > (defn db-grade-range > "Print rows describing fruit that are within a grade range" > [min max] > (sql/with-connection > db > (sql/with-query-results > res > [(str "SELECT name, cost, grade " > "FROM fruit " > "WHERE grade >= ? AND grade <= ?") > min max] > (doseq [rec res] > (println rec))))) > > I haven't yet tried to work with CallableStatements. In reading about > them, I see that they need some more setup (registering OUT parameters > for example) than PreparedStatements do. > > At one point, someone did mention needing access to the current > connection so they could work with them. Since you can call Java > easily from Clojure, working with a particular case (or a few) should > be quite doable without specific support from clojure.contrib.sql. If > you come up with some ideas and suggestions along the lines of with- > query-results (say, with-call-results) that are generally useful, I'll > be happy to work on getting them integrated into clojure.contrib.sql. > > --Steve > > smime.p7s > 3KViewDownload --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---