I have this statement that throws an exception with this message : Unknown
data type: "?, ?"; SQL statement:
val ps =
connection.prepareStatement(
"Select " +
" (case" +
" when (a.streetname = ?) then ?" +
" when (a.streetname = ?) then ?" +
" else ?" +
" end) as v3 " +
"From" +
" address a")
ps.setString(1,"z")
ps.setInt(1,1)
ps.setString(1,"q")
ps.setInt(1,2)
ps.setInt(1,3)
ps.execute()
I've seen in another post that a workaround is possible by putting
values instead of ?, but this opens the door to sql injection.
Is there another workaround ?
Perhaps inserting cast statements around some or all of the arguments, like
:
when (cast ? as String) then (cast ? as int) ... etc ?
Another question, if I do :
case
when cast( ? as String) then cast( ? as int)
when cast( ? as String) then cast( ? as BigDecimal)
otherwise cast(? as float)
will the result be a BigDecimal ?
BTW : H2 rocks big time !
Thanks
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/h2-database/-/IXB69zFmTF0J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.