Question
========
How can I have clojure-contrib sql execute and return arbitrary SQL
SELECT statement?
Example
========
This statement:
(defn db-read []
(sql/with-connection db
(sql/with-results res
"SELECT
users.id,
users.name,
roles.name
FROM
users
INNER JOIN
roles
ON
user.id = roles.user_id
ORDER BY
users.id;"
(doseq [rec res]
(println rec)))))
(db-read)
bombs for me with the follwing exception:
java.lang.IllegalStateException: Var scrapbook/db-read is unbound.
(NO_SOURCE_FILE:0)
I narrowed it down to the reference of the second table as a column.
I.e. the following works fine:
(defn db-read []
(sql/with-connection db
(sql/with-results res
"SELECT
users.id,
users.name,
roles.name
FROM
users
INNER JOIN
roles
ON
user.id = roles.user_id
ORDER BY
users.id;"
(doseq [rec res]
(println rec)))))
But obviously I don't get all the data I need/want.
Any help is appreciated.
-ck
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---