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

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to