Fork me on GitHub
#sql
<
2018-05-16
>
myguidingstar01:05:24

how do I parameterize the time string in this: (jdbc/query db ["select TIME '9:00:00'"])

myguidingstar01:05:26

I've tried (jdbc/query db ["select TIME ?" "'9:00:00'"]), (jdbc/query db ["select TIME ?" "9:00:00"]) and (jdbc/query db ["select TIME '?'" "9:00:00"]) but none of them works

seancorfield01:05:29

I've never seen that syntax but I wouldn't expect you to be able to parameterize that part of a select.

myguidingstar02:05:50

actually it's part of an overlaps. I used select here to simplify my question

myguidingstar02:05:36

I guess it'll be cast type's job there

myguidingstar02:05:32

so I ended up with (jdbc/query db ["select cast (? as time)" "9:00:00"])

4
xlevus19:05:47

@myguidingstar with Postgres, I think you can also wrap the parameterised value with a org.postgresql.util.PGObject,

(doto (PGobject.) 
  (.setType "time") 
  (.setValue "9:00:00"))
(This works with jsonb, don't see why it wouldn't with times)