It looks like there are two issues here...

On Tue, Apr 24, 2012 at 8:04 PM, Michael <michael-a...@db.com> wrote:
> (defn- oracle-insert-sql [table pk-col-name pk-seq-name ks]
>   (let [cols (apply str (interpose \, (map jdbc/as-identifier ks)))
>         n (count ks)
>         qmarks (apply str (interpose \, (repeat n \?)))]
>     (str "insert into " (jdbc/as-identifier table)
>          \( (jdbc/as-identifier pk-col-name) \, cols ") values ("
>          (jdbc/as-identifier pk-seq-name) ".nextval," qmarks \))))

You can't use insert-values because you don't want all the ?
parameters - you want one of them to be a specific expression
(seq.nextval in this case).

> (defn oracle-insert-record [table pk-col-name pk-seq-name record]
>   (let [sql (oracle-insert-sql table pk-col-name pk-seq-name (keys record))]
>     (with-open [^PreparedStatement pstmt (.prepareStatement
> (jdbc/connection) sql,
>                                                             (into-array
> [(jdbc/as-identifier pk-col-name)]))]
>       (set-parameters pstmt (vals record))
>       (jdbc/transaction
>        (.executeUpdate pstmt)
>        (vec (ijdbc/resultset-seq* (.getGeneratedKeys pstmt)))))))

You need a way to pass that array of column names in (the value-groups
already allow for set-parameters as you need them).

Am I correct in my analysis of your needs?

The latter could be provided as an additional optional named parameter
to insert-values. The former I'm not sure of the best approach yet.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

-- 
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

Reply via email to