I have decided to use binding to tackle this for now: (defn do-prepared-insert [...] ;; custom version of do-prepared ... (into [] (resultset-seq (.getGeneratedKeys stmt))))
(defn save-rows-returnid [...] ;; custom update-or-insert-rows ...) (binding [do-prepared do-prepared-insert update-or-insert-rows save-rows-returnid] (update-or-insert-rows ....)) Please let me know your comments. Regards, Shantanu On Aug 12, 3:26 am, meb <meba...@gmail.com> wrote: > I have my own custom version where I bind the generated keys in the > metadata of the returned seq. I think that's only valuable for > clojure 1.2 though. > > The problem with returning an int is that many keys might be > generated, though by the far the most common usage is simply an > autoincrement column on id. > > Mark > > On Aug 11, 1:25 am, Shantanu Kumar <kumar.shant...@gmail.com> wrote: > > > > > > > > > Noticed that thread earlier. I hope this fresh thread is noticed by > > Stephen (C. Gilardi) and others and a consensus can be reached on this > > to do in c.c.sql proper. > > > Cheers, > > Shantanu > > > On Aug 11, 1:15 pm, Remco van 't Veer <rwvtv...@gmail.com> wrote: > > > > There was a thread about this some months ago; > > > > http://groups.google.nl/group/clojure/browse_thread/thread/e95d477830... > > > > Somebody came up with his own version of insert-record: > > > > http://gist.github.com/373564#LC62 > > > > On 2010/08/11 09:10, Shantanu Kumar wrote: > > > > > Hi, > > > > > I need to retrieve auto-generated IDs after executing INSERT > > > > statements (c.c.sql/insert-values ...). Inspecting c.c.sql sources > > > > reveals that (in c.c.sql/do-prepared) a prepared statement is made > > > > with the connection and then the SQL statement is run in that context. > > > > It appears there is a standard API to retrieve the auto-generated IDs: > > > > >http://download-llnw.oracle.com/javase/6/docs/api/java/sql/Statement....() > > > > > However, this method needs the (prepared) statement object to run. I > > > > would suggest adding another "do-prepared-insert" method that does > > > > same things as do-prepared but rather return the following: > > > > > (.getGeneratedkeys stmt) > > > > > Function "insert-values" may be made to call "do-prepared-insert" to > > > > suit this. > > > > > Cheers, > > > > Shantanu -- 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