Sets an array parameter on statement.
Sets an array parameter on statement.
java.sql.Array
SQL("INSERT INTO Table(arr) VALUES {a}").on("a" -> Array("A", "2", "C"))
Sets a binary stream as parameter on statement.
Sets a binary stream as parameter on statement.
For null
value, setNull
with LONGVARBINARY
is called on statement.
SQL("INSERT INTO Table(bin) VALUES {b}").on("b" -> inputStream)
Sets a blob as parameter on statement.
Sets a blob as parameter on statement.
For null
value, setNull
with BLOB
is called on statement.
val blob = con.createBlob() blob.setBytes(1, byteArray) SQL("INSERT INTO Table(bin) VALUES {b}").on("b" -> blob)
Sets boolean value on statement.
Sets boolean value on statement.
SQL("SELECT * FROM Test WHERE enabled = {b}").on('b -> true)
Sets byte value on statement.
Sets byte value on statement.
SQL("SELECT * FROM Test WHERE flag = {b}").on('b -> 1.toByte)
Sets character as parameter value.
Sets character as parameter value.
SQL("SELECT * FROM tbl WHERE flag = {c}").on("c" -> 'f')
Sets a character stream as parameter on statement.
Sets a character stream as parameter on statement.
For null
value, setNull
with VARCHAR
is called on statement.
SQL("INSERT INTO Table(chars) VALUES {c}").on("c" -> reader)
Sets Java Character as parameter value.
Sets Java Character as parameter value.
For null
character, setNull
with VARCHAR
is called on statement.
SQL("SELECT * FROM tbl WHERE flag = {c}"). on("c" -> new java.lang.Character('f'))
Sets date as statement parameter.
Sets date as statement parameter.
For null
value, setNull
with TIMESTAMP
is called on statement.
SQL("UPDATE tbl SET modified = {d}").on('d -> new Date())
Sets double value on statement.
Sets double value on statement.
SQL("SELECT * FROM Test WHERE flag = {b}").on('b -> 1d)
Sets float value on statement.
Sets float value on statement.
SQL("SELECT * FROM Test WHERE flag = {b}").on('b -> 1f)
Sets integer value on statement.
Sets integer value on statement.
SQL("SELECT * FROM Test WHERE flag = {b}").on('b -> 1)
Sets Java Integer object on statement.
Sets Java Integer object on statement.
For null
value, setNull
with INTEGER
is called on statement.
SQL("SELECT * FROM Test WHERE flag = {b}"). on('b -> new java.lang.Integer(1))
Sets Java big decimal on statement.
Sets Java big decimal on statement.
Value null
is accepted.
SQL("UPDATE tbl SET max = {m}").on('m -> new java.math.BigDecimal(10.02f))
Sets Java big integer on statement.
Sets Java big integer on statement.
For null
value, setNull
with NUMERIC
is called on statement.
SQL("UPDATE tbl SET max = {m}").on('m -> new BigInteger(15))
Sets Java Boolean object on statement.
Sets Java Boolean object on statement.
For null
value, setNull
with BOOLEAN
is called on statement.
SQL("SELECT * FROM Test WHERE enabled = {b}"). on('b -> java.lang.Boolean.TRUE)
Sets Java Byte object on statement.
Sets Java Byte object on statement.
For null
value, setNull
with TINYINT
is called on statement.
SQL("SELECT * FROM Test WHERE flag = {b}").on('b -> new java.lang.Byte(1))
Sets Java Double object on statement.
Sets Java Double object on statement.
For null
value, setNull
with DOUBLE
is called on statement.
SQL("SELECT * FROM Test WHERE flag = {b}"). on('b -> new java.lang.Double(1d))
Sets Java Float object on statement.
Sets Java Float object on statement.
For null
value, setNull
with FLOAT
is called on statement.
SQL("SELECT * FROM Test WHERE flag = {b}"). on('b -> new java.lang.Float(1f))
Sets Java Long object on statement.
Sets Java Long object on statement.
For null
value, setNull
with BIGINT
is called on statement.
SQL("SELECT * FROM Test WHERE flag = {b}"). on('b -> new java.lang.Long(1l))
Sets Java Short object on statement.
Sets Java Short object on statement.
For null
value, setNull
with SMALLINT
is called on statement.
SQL("SELECT * FROM Test WHERE flag = {b}"). on('b -> new java.lang.Short(1.toShort))
Sets multi-value parameter from list on statement.
Sets multi-value parameter from list on statement.
SQL("SELECT * FROM Test WHERE cat IN ({categories})"). on('categories -> List(1, 3, 4)
Sets long value on statement.
Sets long value on statement.
SQL("SELECT * FROM Test WHERE flag = {b}").on('b -> 1l)
Sets opaque value as statement parameter.
Sets opaque value as statement parameter. UNSAFE: It's set using java.sql.PreparedStatement.setObject.
SQL("EXEC indexed_at {d}").on('d -> anorm.Object(new java.util.Date()))
Sets optional A inferred as Option[A].
Sets optional A inferred as Option[A].
SQL("SELECT * FROM Test WHERE category = {c}").on('c -> Option("cat")) SQL"SELECT * FROM Test WHERE nullable_int = \${Option.empty[Int]}"
Sets big decimal on statement.
Sets big decimal on statement.
For null
value, setNull
with DECIMAL
is called on statement.
SQL("UPDATE tbl SET max = {m}").on('m -> BigDecimal(10.02f))
Sets big integer on statement.
Sets big integer on statement.
For null
value, setNull
with NUMERIC
is called on statement.
SQL("UPDATE tbl SET max = {m}").on('m -> BigInt(15))
Sets multi-value parameter on statement, with custom formatting (using anorm.SeqParameter).
Sets multi-value parameter on statement, with custom formatting (using anorm.SeqParameter).
import anorm.SeqParameter SQL("SELECT * FROM Test t WHERE {categories}"). on('categories -> SeqParameter( values = Seq("a", "b", "c"), separator = " OR ", pre = "EXISTS (SELECT NULL FROM j WHERE t.id=j.id AND name=", post = ")"))
Sets multi-value parameter from sequence on statement.
Sets multi-value parameter from sequence on statement.
SQL("SELECT * FROM Test WHERE cat IN ({categories})"). on('categories -> Seq("a", "b", "c")
Sets multi-value parameter from set on statement.
Sets multi-value parameter from set on statement.
SQL("SELECT * FROM Test WHERE cat IN ({categories})"). on('categories -> Set(1, 3, 4)
Sets short value on statement.
Sets short value on statement.
SQL("SELECT * FROM Test WHERE flag = {b}").on('b -> 1.toShort)
Sets not empty optional A inferred as Some[A].
Sets not empty optional A inferred as Some[A].
SQL("SELECT * FROM Test WHERE category = {c}").on('c -> Some("cat"))
Sets multi-value parameter from sorted set on statement.
Sets multi-value parameter from sorted set on statement.
SQL("SELECT * FROM Test WHERE cat IN ({categories})"). on('categories -> SortedSet("a", "b", "c")
Sets multi-value parameter from stream on statement.
Sets multi-value parameter from stream on statement.
SQL("SELECT * FROM Test WHERE cat IN ({categories})"). on('categories -> Stream(1, 3, 4)
Sets string as parameter value.
Sets string as parameter value.
Value null
is accepted.
SQL("SELECT * FROM tbl WHERE name = {n}").on("n" -> "str")
Sets timestamp as statement parameter.
Sets timestamp as statement parameter.
Value null
is accepted.
SQL("UPDATE tbl SET modified = {ts}"). on('ts -> new Timestamp(date.getTime))
Sets a wrapped timestamp as statement parameter.
Sets a wrapped timestamp as statement parameter.
For null
value, setNull
with TIMESTAMP
is called on statement.
val wrapper = new { // Any value with a `.getTimestamp` val getTimestamp = new java.sql.Timestamp(123L) } SQL("UPDATE tbl SET modified = {ts}").on('ts -> wrapper)
Sets UUID as statement parameter.
Sets UUID as statement parameter.
For null
value, setNull
with VARCHAR
is called on statement.
SQL("INSERT INTO lang_tbl(id, name) VALUE ({i}, {n})"). on("i" -> JUUID.randomUUID(), "n" -> "lang")
Sets multi-value parameter from vector on statement.
Sets multi-value parameter from vector on statement.
SQL("SELECT * FROM Test WHERE cat IN ({categories})"). on('categories -> Vector("a", "b", "c")
Sets null for None value.
Sets null for None value.
SQL("SELECT * FROM Test WHERE category = {c}") .on('c -> None)
(Since version 2.3.7) Parameter value should be passed using Option.empty[T]