Hi, I wonder if its possible to convert this database query (its CLR) into
a lazy sequence.
The reader loop is wrapped in the opening and closing of the db-connection
and reader.
When i 'take a few records from the sequence, will then the connection be
closed
because it's getting out of scope and will be garbage collected ?
How is it possible ?
(defn user [conn-str]
(let [conn (System.Data.SqlClient.SqlConnection. conn-str)
_ (.Open conn)
cmd (System.Data.SqlClient.SqlCommand.
(str "SELECT name from User") conn)
reader (.ExecuteReader cmd)]
(let [out (loop [out '()]
(if (.Read reader)
(do
(print ".")
((recur (conj out (.GetString reader 0)))))
out))]
(.Close reader)
(.Close conn)
out)))
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.