David,
Thank you for asking this question. I am not sure why I need a defrecord. I am new to clojure and come from OO background. In Java for example one would immediately take the result set and convert it to objects. Is there any advantage to converting to defrecord? I read Clojure has other features like protocols that work better with defrecords. Should I wait until I require those features and just continue to work directly with maps? Is there any disadvantage to working with plain maps? Thanks Shoeb ________________________________ From: clojure@googlegroups.com [mailto:clojure@googlegroups.com] On Behalf Of David Nolen Sent: Wednesday, April 13, 2011 4:01 PM To: clojure@googlegroups.com Subject: Re: Creating defrecords from results of a sql query On Wed, Apr 13, 2011 at 3:43 PM, Bhinderwala, Shoeb <sabhinderw...@wellington.com> wrote: I am considering moving the results of with-query-results into defrecords. What is the best way to achieve this? I wrote the following but it hits the limitation of 20 parameters and I get an exception: (defrecord PerfRecord [perf-dt grp-id sec-id asset-class beg-mv-base end-mv-base beg_mv_locl end_mv_locl net_out_flows_base net_in_flows_base net_inc_flows_base accr_fx_base net_out_flows_locl net_in_flows_locl net_inc_flows_locl beg_accrued_base end_accrued_base beg_accrued_locl shares base_curcy_cd end_accrued_locl sec_typ1 sec_typ2 perf_curcy_cd price_curcy_cd]) (defn to-records [res] (apply #(PerfRecord. %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16 %17 %18 %19 %20 %21) res)) (defn get-data [] (sql/with-connection dbconn (sql/with-query-results res [query-str] (to-records res)))) Is there a better way to write the to-records method? -- Shoeb Any reason to not just use maps? David -- 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 Note that posts from new members are moderated - please be patient with your first post. 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 -- 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 Note that posts from new members are moderated - please be patient with your first post. 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