A "sql" string interpolator that provides functionality to create SqlWithParams instances like:
A "sql" string interpolator that provides functionality to create SqlWithParams instances like:
val id = 10 val stmt = conn.statement(sql"select * from test where id = $id")
The code above produces select * from test where id = ?
statement
with the sole parameter bound to value 10
.
The interpolator supports also literal values that allow to dynamically construct statements. To use this feature, instead of $, use #$, for example:
val id = 10 val table = "test" val stmt = conn.statement(sql"select * from #$table where id = $id")
The code above produces select * from test where id = ?
statement
with the sole parameter bound to value 10
.