This may be a duplicate post, if so I apologize. I am having a problem
while investigating the inner workings and capabilities of the
clojure.contrib.sql class, specifically with the "inner join" syntax.
I have a function that returns recordset maps that is taken directly
from the test.clj file in the clojure.contrib.sql folder.  It returns
data properly from database (works with SQL Server and HSQLDB so far),
even works when calling stored procedures.  However, whenever I insert
a SQL query that contains an inner join command (standard SQL), I get
the following error:
java.lang.RuntimeException: java.lang.RuntimeException:
java.lang.IllegalArgumentException: Too many arguments to struct
constructor (NO_SOURCE_FILE:0)
        at clojure.lang.Compiler.eval(Compiler.java:4186)
...and more

My function is simple:
(defn db-join-read
  "Read joined counties and states tables"
  []
  (sql/with-connection
   db
   (sql/with-query-results
    res
    ["SELECT * FROM counties inner join states on counties.StateJID =
states.StateID"]
     (dorun (map #(println %) res)))))

If I substitute the other types of SQL statements mentioned above
(SELECT statements from one table, stored procedures, anything other
than inner join statements) into the string that is in the vector in
the function, everything executes ok, and I get back maps of
records.

However, inner joins generate the error above, both using Microsoft's
SQL Server JDBC driver and in HSQLDB using its own JDBC driver, so I
suspect the problem lies in the clojure.contrib.sql code, either I am
not formatting inner join statements properly for  clojure.contrib.sql
(which is entirely possible), or there is an issue with SQL inner
joins (maybe how JDBC implements them?) and this library.

Does anyone have any sample code which uses clojure.contrib.sql and
utilizes INNER JOIN statements.  My only other option is to include
all inner join queries in stored procedures (which I know are executed
properly even if there are inner join with the SP). Thanks in advance
for any assistance.

Brian
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to