Fork me on GitHub
#sql
<
2018-03-26
>
bwstearns22:03:55

So this might come off as a dumb question (perhaps I’m just failing at my google fu), but is there a way to parameterize for multiple rows? Basically I have

INSERT INTO foo (a, b, c)
VALUES -- looking what to put here for parameterizing multiple rows
ON CONFLICT
-- a bunch of other stuff not supported by my ORM

bwstearns22:03:53

Do I need to make code to generate n number of (?, ?, ?) rows to insert into the prepared statement?

rymndhng22:03:11

@bwstearns does this work ((?, ?, ?), (?, ?, ?))? or (?, ?, ?), (?, ?, ?)

tanzoniteblack22:03:47

@bwstearns correct, using the raw sql strings there's no way to do that. http://clojure.github.io/java.jdbc/#clojure.java.jdbc/insert-multi! attempts to make it so you don't need to do that, but as far as I know that won't work with on conflict. For queries like this either you need to generate n number of (?, ?, ?) rows, or use a helper library (like hugsql or honeysql). I personally think things like this are easier done with honeysql

bwstearns22:03:59

thanks for the input. I think my googling had gotten too verbose so I was getting lots of non-relevant answers, so I guess i need to build out the n dummy strings before combining them.