I am doing the following after an insert for a Derby database:
(sql/with-query-results res
["VALUES IDENTITY_VAL_LOCAL()"]
(first (vals (first res))))
For MySQL it would be something like:
(sql/with-query-results res
["SELECT LAST_INSERT_ID()"]
(first (vals (first res))))
I am not sure if it's actually safe to do it this way, considering
connection pooling etc. It sure is ugly..
Saul Hazledine <[email protected]> writes:
> Hello,
> I'm using clojure.contrib.sql/insert-records to add data to a
> database. I've hit a problem where I am unable to get the
> autogenerated IDs of the records that I have inserted.
>
> I believe in JDBC this is normally done with
> statement_handle.getGeneratedKeys(). Unfortunately, as far as I can
> see, the statement handle is unavailable to the users of
> clojure.contrib.sql. Has anyone else had this problem?
>
> Saul Hazledine
--
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