On Aug 11, 10:15 am, 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
Thanks for
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
There was a thread about this some months ago;
http://groups.google.nl/group/clojure/browse_thread/thread/e95d4778301be699/
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
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;
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
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